Skip to main content

All Questions

Tagged with
1 vote
1 answer
100 views

How to mock a no response from server with Gin Golang

I'm mocking a server for testing my application. I built the mocked server with Golang and Gin. It works well for successful cases. But one of the cases I want to test is how the application behaves ...
Julio Martínez's user avatar
2 votes
1 answer
287 views

Additional "id" field generated when posting into MongoDB

I'm learning Go and Gin framework. I built a simple microservice connected to a MongoDB collection, everything works but when I add a document using a POST it adds the "id" field instead of ...
user avatar
2 votes
1 answer
2k views

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 ...
dogbullet's user avatar
2 votes
0 answers
757 views

golang call handler inside a handler

I want to use existing handler without actually send http request (http.Do or something like that), so I use gin.CreateTestContext(httptest.NewRecorder()) to create new *gin.Context to call existing ...
Hoshizora-N's user avatar
1 vote
0 answers
246 views

How to write a function to update an object's information using PATCH request Go a Gin-Gonic?

I have the following code: package main import ( "net/http" "github.com/gin-gonic/gin" "strconv" "fmt" ) // album represents data about a ...
Ricky Osgood's user avatar
1 vote
1 answer
567 views

Adding information to Golang Gin HTTP error responses

I am trying to return a custom error response when an HTTP 500 Internal Error is encountered. If I use c.JSON(http.StatusInternalServerError, CustomError{}) when a database write error occurs, Gin ...
Кафка's user avatar
0 votes
0 answers
1k views

How to send a request with query parameters in gin

I am trying to create a route for GET request with the username parameter. After sending the request from postman as localhost:9090/user/?username=abc I am unable to get the response. It is showing ...
Priyanka Salunke's user avatar
-1 votes
2 answers
73 views

Golang RESTAPI returns wrong data

When i use the debugger the metricId returns the Metric Object with all 0 or null values (same as the output). what am i doing wrong here? The Database connection works. func GetMetricById(c *gin....
Qukz's user avatar
  • 47
1 vote
1 answer
3k views

Read file in request body with Go Gin [duplicate]

I'm getting empty file when I try to read the request body of my HTTP request using Go Gin. On my request I'm sending a file attached to the Request Body (Content Type: application/octet-stream). ...
Loren's user avatar
  • 333
0 votes
1 answer
2k views

go api with gin gonic PATCH request not working

I am a beginner in go trying to write my first simple API using the gin gonic framework. I have a mock set of data in a struct that holds information about a number of books available in a library. ...
Beatrix's user avatar
  • 55
1 vote
1 answer
3k views

Go GIN context parse unexpected query string

I have different structs for the query in the REST request. I'd like to return HTTP 400: BAD REQUEST when the query string contains an unexpected parameter than my struct. type FilterData struct { ...
Taylan Yuksel's user avatar
0 votes
1 answer
2k views

How to download files using Swag golang library?

I am trying to make a REST API using gin-gonic in golang, which takes some path parameters from a GET request & downloads that file. That works correctly by curl command. However, when I add ...
user avatar
0 votes
1 answer
264 views

Skip binding ID but return it as a response

I have a Person struct as follows: type Person struct { ID primitive.ObjectID `bson:"_id,omitempty" json:"id"` HomeAddress Address `bson:"home_address" json:"...
nanakondor's user avatar
0 votes
0 answers
1k views

Download occurs at my custom gin-golang based REST server side, but not occurring at client side

I am creating an HTTP REST server in golang using gin-gonic My code is: func main() { var port string if len(os.Args) == 1 { port = "8080" } else { port = os....
user avatar
4 votes
2 answers
8k views

How to avoid Golang server (Gin Gonic) to crash on INTERNAL_ERROR

first of all : I'm new to Go, I come from years of java development. I have developed a little REST API using Gin Gonic. One of my endpoint occasionally (so I can't reproduce on demand) crashes ...
tlebrun06's user avatar
  • 101

15 30 50 per page