gin路由报错

panic: wildcard route ':id' conflicts with existing children in path '/:id'
测试代码

package main
import "github.com/gin-gonic/gin"

func main() {
    r := gin.Default()

    r.GET("/name", func(c *gin.Context){
        c.String(200, "name")
    })

    r.GET("/:id", func(c *gin.Context){
        c.String(200, "id")
    })
    // Listen and server on 0.0.0.0:8080
    r.Run(":8080")
}

共 2 个回复


jimmykuu

路由冲突了,/name 包含在 /:id 里面

# 0