标签:code inf http str rgb %s package contex port
package main import ( "fmt" "net/http" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/user", func(c *gin.Context) { //指定默认值 name := c.DefaultQuery("name", "枯藤") c.String(http.StatusOK, fmt.Sprintf("hello %s", name)) }) //默认监听8080端口 r.Run(":8080") }
不传递参数输出结果:
标签:code inf http str rgb %s package contex port
原文地址:https://www.cnblogs.com/ckfuture/p/14945403.html