Questions tagged [gin]

52 questions
1
vote
0 answers

GoSwagger wrong color for @Failure routes

I put the following description at the top of my function however the failure routes are displayed in green just as the success one in my browser: . // Register godoc // @Schemes // @Description Create a user // @Tags register // @Accept json //…
Kaido
  • 11
  • 1
1
vote
0 answers

How did Gin generate SSL certificate for me although port 80 and CNAME are blocked?

I've been trying to get a SSL certificate, but my ISP blocks port 80 and my domain service doesn't allow to set CNAME records. As I way about to give up I stumbled upon autotls which is a feature of some Golang web frameworks and it magically…
funtoomen
  • 21
  • 4
1
vote
2 answers

difference between Json.Unmarshal() and gin.BindJson()

hi i'm new to gin framework and golang and i was wondering what's the difference between Json.Unmarshal() and gin.BindJson() in the tutorial he's building a video service which has two methods, save and findall func (vc *videoControllerStruct)…
buchana
  • 23
  • 4
1
vote
1 answer

Why go can't access port 8080 in docker

So I want to deploy my simple Go backend in Cloud Run. I use Gin to handle the routing. My main function that handle it look like this: func main() { r := gin.Default() r.GET("/api/health", handlers.HealthCheckHandler()) …
1
vote
0 answers

How to do a unit-test in Handler layer in go?(Using gorm,,gin)

Recently I started writing unit tests on go.I received a task to conduct tests on all layers.I did it successfully on the repository and service layer, but there were problems on the handlers.I corny just don't understand how to write it here. func…
Cor4ik
  • 11
  • 2
1
vote
0 answers

How to switch to https on Golang Gin?

I've been looking for a way to switch to https in my Golang server. I thought I found the way already, which involved generating .pem and .key files and passing them as some sort of credentials, but it didn't work. Here's what my current code looks…
rminaj
  • 560
  • 6
  • 28
1
vote
1 answer

Swag init generates nothing but "general API information"

Issue Description Swaggo fails to recursively parse Swagger comments in Go files when using the swag init command with multiple directories and the --parseDependency and --parseInternal flags. Only the comments in the main file specified with the -g…
dogbullet
  • 19
  • 2
1
vote
0 answers

Golang catch error (panic) with Goroutines

I write some gin application func (h Handler) GetOptions(context *gin.Context) { // skip outputChan := make(chan shipping.Results) inputChan := make(chan shipping.Option) var waitGroup sync.WaitGroup go handleResults(inputChan,…
Smirnov
  • 137
  • 3
  • 12
1
vote
0 answers

CPU usage increasing day by day because of Cron

I am running a cron whose code is written in Golang,and i am using mongoDb(version -4.4) as database, the cron runs after every 5 minutes of interval, i have been noticing that when i start the cron within a week the cpu usage hikes from 0 to 60% or…
rohit
  • 89
  • 5
1
vote
0 answers

Do not send the OK header before io.Pipe has data

In HTTP server I'm trying to pipe a file from a io.Writer to io.Reader. I'm using io.Pipe to transfer the data. The common pattern for this seems to be something like this: // Some handler func .. pr, pw := io.Pipe() go func() { defer…
Paperclip
  • 615
  • 5
  • 14
1
vote
1 answer

Passing the handler in route group without creating condition

I wanted to create a route group wherein I can only passed the "repo.GetUsers" only and not create an if statement, for simplicity. I'm practicing a crud application and if someone can help me solve this, then it would be a really big help. package…
Omega
  • 13
  • 4
1
vote
1 answer

Golang send PDF as attachment in email

I am working on an task in which i have to send pdf file as attachment in email, i'm using the Golang AWS SES-v2 package for sending emails. Earlier i was just sending all the emails without any attachment which consists of subject and body. input…
rohit
  • 89
  • 5
1
vote
1 answer

Gin gonic framework: confusing response status codes

I've stepped into something I don't understand. Here is an example of Gin API route handler, written in Golang. // src/file1.go func CreateDataModelAction(c *gin.Context) { var input inputs.CreateDataModelInput if err :=…
Andrey Korchak
  • 2,280
  • 1
  • 18
  • 15
1
vote
0 answers

Cannot use 'kendaraan' (type entities.kendaraan) as the type *gin.Context

Please Help to solve this error! I made a code for parsing from my html like this: parsehtml.go func addData(w *http.ResponseWriter, r *http.Request, c *gin.Context) { if r.Method == http.MethodGet { temp, err :=…
MiPremix
  • 11
  • 2
1
vote
3 answers

golang: How to remove spaces and line breaks in the request body

I wrote a web service (golang) using the gin framework to receive parameters in json body format. I make a request like this: curl --location 'http://foo.bar/test' \ --header 'Content-Type: application/json' \ --data'{ "a": "1", "b":…
andy ng
  • 23
  • 4