package main import ( "fmt" "github.com/gin-gonic/gin" "net/http" ) func getPath(ctx *gin.Context) { id := ctx.Param("id") ctx.JSON(http.StatusOK, gin.H{ "id": id, }) } func main() { router := gin.Default() router.GET("/user/:id", getPath) err := router.Run(":8080") if err != nil { fmt.Println(err) return } }