can I use goroutione like:
router := gin.Default() go router.POST("test", func(c *gin.Context) { ...... })
Comment From: delphinus
What do you want? gin is based on net/http
package, and that serves each request by an individual goroutine. You do not need to worry about it.
Comment From: thinkerou
Maybe you should see https://github.com/gin-gonic/gin#goroutines-inside-a-middleware firstly.
Comment From: fwhezfwhez
gin only focuses on control layer,which only deals with message from a client,and its reply,learn goroutine you should learn go basic grammar,and basicly like:
go func(){
fmt.Println("I'm a new routine")
}()
Comment From: thinkerou
closing.
Comment From: apriil15
What do you want? gin is based on
net/http
package, and that serves each request by an individual goroutine. You do not need to worry about it.
I would like to give some advice to those who have the same question as me. 1. check the comment: https://pkg.go.dev/net/http#Serve 2. use a little time to trace source code: https://github.com/golang/go/blob/08e39a196186b0b2ce852a156515001b8de190dc/src/net/http/server.go#L3084