#3059·gin

Confusing Blocks in Groups Documentation Code snippet

Author: ajibigadCreated Feb 20, 2022Updated Sep 27, 2026

Hi,

This is a question or suggestion.

The blocks used in this example of grouping routes are quite confusing.

v1 := router.Group("/v1")
{
  v1.POST("/login", loginEndpoint)
  v1.POST("/submit", submitEndpoint)
  v1.POST("/read", readEndpoint)
}

I had similar confusion as asked in this question.

At a glance, it looked like the blocks were a part of the router.Group("/v1") statement, like a struct being initialized with a struct literal.

My question: Are there any reasons the blocks were used?

If there aren't, I think the blocks should be removed to avoid confusion.

Thanks