I have been developing in Node/Python for years, and over the holiday I have been trying to expand my knowledge of Go. I have a pet project that I've been working on to learn it.
As I have been reading the gin-gonic documentation, I found syntax that I can't wrap my head around.
func main() {
router := gin.Default()
// Simple group: v1
v1 := router.Group("/v1")
{
v1.POST("/login", loginEndpoint)
v1.POST("/submit", submitEndpoint)
v1.POST("/read", readEndpoint)
}
// Simple group: v2
v2 := router.Group("/v2")
{
v2.POST("/login", loginEndpoint)
v2.POST("/submit", submitEndpoint)
v2.POST("/read", readEndpoint)
}
router.Run(":8080")
}
Basically, it looks like the router.Group()
method takes in a struct, but I am not quite sure what the mechanics are here... It's not wrapped in parentheses. How is this object being passed in/handled by the Group
method?