🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
文档:https://www.kancloud.cn/jiajunxi/ginweb100/1801414 官方文档: https://learnku.com/docs/gin-gonic/1.7/go-gin-document/11352 安装 ``` 1. go version ( 1.7.0 以前 ) go get -u github.com/gin-gonic/gin 2. go version ( 1.7.0 以后 ) go install github.com/gin-gonic/gin@latest ``` go mod init xxx(项目名称) 用这个管理项目依赖包。 import "github.com/gin-gonic/gin" 3.(可选)如果使用诸如 http.StatusOK 之类的常量,则需要引入 net/http 包: import "net/http" 运行示例 1. 创建项目并且 cd 到项目目录中 (也可以把项目放到你想放的任何地方,使用 go mod 的好处就是不必强制把项目放到 GOPATH 下了) $ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_" 2. 初始化 go mod $ go mod init project 3. 启动项目 ``` import "github.com/gin-gonic/gin" 3.(可选)如果使用诸如 http.StatusOK 之类的常量,则需要引入 net/http 包: import "net/http" 运行示例 1. 创建项目并且 cd 到项目目录中 (也可以把项目放到你想放的任何地方,使用 go mod 的好处就是不必强制把项目放到 GOPATH 下了) $ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_" 2. 初始化 go mod $ go mod init project 3. 启动项目 $ go run main.go ``` 运行起来项目:demo01