Gin: how to use Goroutine in Gin

Created on 25 Apr 2018  路  4Comments  路  Source: gin-gonic/gin

can I use goroutione like:

router := gin.Default()
go router.POST("test", func(c *gin.Context) {
......
})

question

Most helpful comment

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.

All 4 comments

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.

Maybe you should see https://github.com/gin-gonic/gin#goroutines-inside-a-middleware firstly.

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")
}()

closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gplume picture gplume  路  3Comments

Bloomca picture Bloomca  路  3Comments

rawoke083 picture rawoke083  路  3Comments

nxvl picture nxvl  路  3Comments

wangcn picture wangcn  路  3Comments