要安装Gin包,你须要先去安装GO,而且设置好GO的工做区git
下载并安装Gin宝:github
$ go get -u github.com/gin-gonic/gin
在你的代码中引入该包:curl
import "github.com/gin-gonic/gin"
(可选项) 导入 “net/http
”包.有时候你必需要导入这个包,例如当你在使用“http.StatusOK
”这种静态变量的时候,工具
import "net/http"
使用go get 命令获取govendorfetch
$ go get github.com/kardianos/govendor
建立你的应用目录,而且使用cd命令进入到该目录url
$ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_"
使用包管理工具初始化你的项目而且安装ginspa
$ govendor init $ govendor fetch github.com/gin-gonic/gin@v1.2
建立一个新手模版到你的项目中code
$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go
运行项目get
$ go run main.go