go-gin构建
installation To install Gin package, you need to install Go and set your Go workspace first.
- Download and install it:
【go初始化gin项目】$ go get -u github.com/gin-gonic/gin
- go get govendor:
$ go get github.com/kardianos/govendor
- Create your project folder and cd inside:
$ mkdir -p $GOPATH/src/gin.com/gintest/ && cd "$_"
- Vendor init your project and add gin:
$ govendor init
$ govendor fetch github.com/gin-gonic/gin@v1.3
- Copy a starting template inside your project:
$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go
- Run your project:
$ go run main.go
到这里 你已经成功的完成了整个初始化环境的搭建,现在,去代码块拉取你的代码,开始开发吧。
在github上拉取代码后,首先需要先拉取第三方依赖,在项目目录下使用:
$ govendor sync
如果是DEMO代码,可以尝试本地跑该项目:
$ go run main.go
推荐阅读
- Go|Docker后端部署详解(Go+Nginx)
- GO|GO,GO,GO!
- Go成长之路|go中判断空字符串、nil和len(t)的用法
- go编译tools
- go grpc安装与使用
- goroutine 调度原理
- Go|Go进阶之路——复杂类型
- Go进阶之路——变量
- Go进阶之路——流程控制语句