export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=/Users/shanwen.ren/Desktop/go/go_project
...输出一堆Go的配置。
go version go1.21.0 darwin/arm64
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
// r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
r.Run(":10240")
}