All Questions
914
questions
-1
votes
0
answers
30
views
How can I render my struct's floats with two decimal places in Go? [duplicate]
I have a struct with fields that are represented by floats. I want to render these floats with two decimal places (either via zero padding or truncation) as part of a response handler in a Gin server. ...
1
vote
2
answers
59
views
Go Gin Framework cors error for gin router group
I am building a full-stack project using Golang and Angular 18. I’ve encountered a CORS issue. When I try to access http://localhost:8080/api/v1/auth/login (POST) from the frontend, there is no CORS ...
0
votes
1
answer
83
views
Compress json file >= 60MB in Go to file tar.gz
When I compress a json file >= 60MB, I get an error that the data is insufficient and only 28MB is available.
func CreateTarGz(sourceDir, targetFile string) error {
target, err := os.Create(...
-4
votes
1
answer
70
views
Does overriding c.Request.Body with io.NopCloser in a Gin middleware cause potential data leaks?
I'm writing a middleware in Gin to log the request body for debugging purposes. In order to read the body multiple times, I need to use io.NopCloser to reassign c.Request.Body. Here's my current ...
1
vote
0
answers
97
views
How can I prevent running out of ports?
sorry if the Title is misleadling I didn't know how to ask it properly. I'll explain my situation as much as I can.
I have a go-gin web server running. Lately it get's stuck. Not responding to ...
1
vote
1
answer
39
views
Validation error is being caught as a decoding error in Go Gin framework
I'm using the Gin framework in Go to bind and validate incoming JSON requests. However, I'm encountering an issue where validation errors are being caught as decoding errors. Specifically, when a ...
1
vote
0
answers
33
views
HTMX Form in Gin Admin Panel Requires Page Reload to Resubmit Changes
I have a form on an admin panel I am working on that doesnt allow me to resubmit changes on it unless I reload the page. I am using HTMX, and GIN primarily:
Form:
<tr data-id="{{ .ID }}"&...
1
vote
0
answers
121
views
Handling large files upload using golang gin router
Assuming that I trust the content length.
I send a POST request to my gin server to upload files and other data. I added a middleware to check the content-length first; and if it is larger than my ...
0
votes
1
answer
79
views
Conditionally load or add another middleware in the chain during current middleware
When using Gin framework for Go, I'm writing some custom middleware. One of my new middleware will evaluate if the request coming in is from my front-end SPA. If it is, I want to also use the sessions ...
1
vote
1
answer
61
views
Cache Control in StaticFS server in Gin Web Framework (Golang)
I am working on an Open Source Go project using Gin Framework. I'm using embedded Templates and Static files for building the executable binaries. Since the static files are embedded, they are not ...
1
vote
0
answers
67
views
How to avoid mistakes with CORS gin?
Every now and then these errors with CORS appear, sometimes there are some, sometimes not, but always if there are, it looks like this:
Access to fetch at 'http://localhost:8080/u/profile/' from ...
1
vote
1
answer
44
views
$sort in aggregate command have inconsistent output when using golang with mongo driver
I have created a endpoint to query all users in a certain school. Every user will have a list of his favorite other user and their favorite point. The query result will be sorted descending based on &...
1
vote
2
answers
111
views
Golang gorm runtime error: invalid memory address appears after a long idle time when using same gorm.db connection
After some hours of running without problems I get the following runtime error:
[ERROR] runtime error: invalid memory address or nil pointer dereference
goroutine 37 [running]:
runtime/debug.Stack()
...
0
votes
1
answer
91
views
How do I handle a crash of a Golang (Gin) web server and recover with a new process?
I am in the process of writing a bunch of APIs. I am going to use Gin.
I will deploy behind a reverse proxy (I am forced to use Apache).
Like any process, I expect the Gin process to crash from time ...
2
votes
0
answers
71
views
GORM adding "AND column.id = 1", why?
Im having an issue with GORM on my GIN project.
Please help me if possible.
My issue is:
var class models.Classrom
old_classID = "algorithm"
DB.Model(&models.Classrom{}).Where("...