Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 19:14
    ssoroka commented #2673
  • 04:44
    qifengzhang007 closed #3280
  • 04:44
    qifengzhang007 commented #3280
  • 01:19
    thinkerou opened #3289
  • Aug 18 07:16
    jsjain commented #3267
  • Aug 18 07:16
    jsjain closed #3267
  • Aug 18 06:18
    praveenk007 commented #857
  • Aug 18 02:03
    thinkerou assigned #2234
  • Aug 18 01:35
    Coverage (#3282) +0.00%
  • Aug 18 01:35
    dependabot[bot] commented #3282
  • Aug 18 01:35
    thinkerou closed #3282
  • Aug 18 01:35

    thinkerou on go_modules


  • Aug 17 16:46
    weedge opened #3288
  • Aug 17 16:29
    pavelpatrin commented #1301
  • Aug 17 08:23
    caiski opened #3287
  • Aug 17 06:09
    codecov[bot] commented #3272
  • Aug 17 06:09
    Coverage (#3272) +0.00%
  • Aug 17 06:08
    codecov[bot] commented #3272
  • Aug 17 06:08
    Coverage (#3272) +0.00%
  • Aug 17 06:07
    codecov[bot] commented #3272
anyone there?
i cant clone
go get -u github.com/gin-gonic/gin
# cd .; git clone -- https://gopkg.in/yaml.v2 /Users/jt/golib/src/gopkg.in/yaml.v2
Cloning into '/Users/jt/golib/src/gopkg.in/yaml.v2'...
fatal: unable to access 'https://gopkg.in/yaml.v2/': SSL certificate problem: certificate has expired
package gopkg.in/yaml.v2: exit status 128
Hello devs! I would like to you to help me out with your opinions. Me & my team have a interesting social networking project on the table. We would like to build it using Go lang. How much do you recommend Gin Gonic for such a project? I'm just doing research on the best possible Go lang frameworks.
2 replies
How can I make a middleware that modifies after next call the headers like?
func ResponseTimeMiddleware(c *gin.Context) {
    startTime := GetUnixTime()
    c.Request.Header.Add("x-response-time", strconv.FormatInt(GetUnixTime()-startTime, 10))
I might be an idiot.
But running go get github.com/gin-contrib/sessions is returning ../../go/pkg/mod/github.com/gin-contrib/sessions@v0.0.4/session_options_go1.10.go:1:1: expected 'package', found 'EOF'
Any ideas?
Danny Lai


I am writing a simple API with gin. routes / request / response all good. Now, i am trying to add some debugs into the route. I know i can log.Print() the messages, but with that, i will not have the context (request id, request body / method etc). I tried looking up a logger middleware that can accept any debug message (log.Print("Working on request" + param.Request.Body)).. but i can't seem to find any. All that said, question: How i can print debug message within a route, such that it has the context, and any debug messages i left in the route? Any example would be great!


Youwei Li
Hi , I'm new to learn and use Gin, could someone tell me how Gin handles high concurrency, by creating a new gouroutine when processing a new requests?
Stanislav Ochotnický
I think I found a bug/weird behaviour wrt caching and StaticFS when using embed - as far as I can tell due to way embed doesn't really provide modified time of files. I wonder if anyone can confirm or I am just confused :-)
Stanislav Ochotnický
re staticFS & embed caching mentioned yesterday - I did end up finding a golang bug that basically addresses that - golang/go#44854
Giovanni Almeida
Hello! How can I contact any repository owner?
Danny Hermes
Is there any way to get code review on gin-gonic/gin#3054 ?
Dikdik Tasdik Laksana
Abdul Saqib
Could anyone please help me to get this point?
What is the use of this package: ginS
How can I get body of post request in JSON?
@SolindekDev use c.BindJSON func to bind to request struct
Kamis bin Bintang
Hello! Excellent Developers! I've just experienced with Gin-Gonic framework. I'm now looking for projects for hands-on practice. Please contact me and give me projects if you have any.
WERCK Ayrton
Hi !
I am looking to use gin to build our next restful API, however our company enforce media type versioning and I did not find a way to route request based on header content without changing the URL
Do you if that's something possible?
this is good
Hi all, I have a function (gin is used) that is talking to the database in the code, and based on the response the logic is written, how to write a unit tests using the testing package without changing the original function?
code in the playground: https://go.dev/play/p/1LpWRtDBatF
how do I create a mock context with all the headers, body, URL, and other details which I am sending from the client, I am stuck here, and also the function is not returning anything so, how do I mock the DB and make it work, how do I write a test which covers 80% code, can you pls suggest
hi, guys. What will happend if the groutine happened oom. Will the main progress will keep running, and the defer function will be executed in the oom's grotine?
Thomas Güttler
Oom kills the process with signal 9. The process can't catch the signal. The whole process gets killed.
Muktar Iberahim
hello i just installed gin to my go app and it give me this ../../go/pkg/mod/github.com/gin-contrib/sse@v0.1.0/sse-decoder.go:1:1: expected 'package', found 'EOF'
../../go/pkg/mod/github.com/go-playground/universal-translator@v0.18.0/benchmarks_test.go:1:1: expected 'package', found 'EOF'
../../go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/0_importpath.go:1:1: expected 'package', found 'EOF'
../../go/pkg/mod/google.golang.org/protobuf@v1.28.0/proto/bench_test.go:1:1: expected 'package', found 'EOF'
../../go/pkg/mod/gopkg.in/yaml.v2@v2.4.0/apic.go:1:1: expected 'package', found 'EOF'
Hi. I'm having trouble serving files through gin. After the first few times(?) of downloading a file through the REST API defined, gin returns a 200 without a body. The code this happens in can be found here: https://github.com/LearningBay24/LearningBay24-backend/blob/7dd8de4d378ff2249b4d72fc81916891cefbf05b/api/api.go#L641=
The file exists on disk with at least read permissions and is not empty or corrupted. NGINX is handling requests on the server, but it is reproducable locally without NGINX.
Is this a known issue? If yes, how do I go about fixing it?
Thanks in advance!
@witcher_:matrix.org You should add some Headers to the http response ctx.Header("Content-Type", "application/octet-stream") ctx.Header("Content-Disposition", "attachment; filename=your file name") ctx.Header("Content-Disposition", "inline;filename=your file name") ctx.Header("Content-Transfer-Encoding", "binary") ctx.Header("Cache-Control", "no-cache") ctx.File(your file path)
Thanks for the answer! In the end it was the caching setting. As a quick fix, the frontend to that project will request files with the "Cache-Control" header set to "no-cache" as setting it on the response in the backend doesn't seem to fix this.

Hi! I'd like to use mutliple auth middlewares, so that at least one must pass for a gin.RouterGroup
Currently I use:

// adapter "github.com/gwatts/gin-adapter"
// ...

and I'd like to add one more JWT verifier, but for a different issuer.
Maybe someone can point me in the right direction? :)

Hi ! I only want to serve http2 request with certain HandlerFunc ,not the whole http server. How to set gin http server to support this ?
@snowlyg do you have any ideas?
i have registered this route auth.GET("/logout", Logout) its just /auth/logout when im on new chrome user i use it once it works and in console it says it made a request but when i go there second time it displays nothing in console and redirects to / heres my logout function
func Logout(c *gin.Context) {
    session := sessions.Default(c)
    err := session.Save()
    if err != nil {
    c.Redirect(301, "/")
Asbjørn Ulsberg
Is it possible that the multitemplate.Renderer doesn't support router.SetFuncMap()? With multitemplate.Renderer registered as the router.HTMLRender, I only get an error trying to access the functions registered with SetFuncMap().
Asbjørn Ulsberg
By gin-contrib/multitemplate#2 it looks like this is unsupported?
Asbjørn Ulsberg
Now I wonder whether it's possible to create a URL from the router. gin-gonic/gin#3256
Good morning! Is gin susceptible to the recent ParseThru exploit, or is it unrelated at all? here's the article: https://thehackernews.com/2022/08/new-parsethru-parameter-smuggling.html
I have this piece of code
but Flush does not work
the client still got all 3 events as a single chunk
So how can I redirect stdout to a websocket for realtime updating of a process running to a web page? ie I have a endpoint that kicks off a process that returns all the output to the gin server console but I want to stream it to a redirected page that connects to a websocket so the user can see the progress
kevin olson
Hi everyone - is this gitter the main spot to for the gin community? is there a slack or a discord?
David Martorana
If I do a BeamToNamed and in the construction of that, stack 4-5 BeamPages, if I do a pop, it removes all the pages... where I'd want a back/pop action to only remove the top-most page
is there a way to do that?