go-gin构建
installation
To install Gin package, you need to install Go and set your Go workspace first.
-
Download and install it:
$ go get -u github.com/gin-gonic/gin
vendor tool
-
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
Then visit 127.0.0.1:8080/ping on browser.
到这里 你已经成功的完成了整个初始化环境的搭建,现在,去代码块拉取你的代码,开始开发吧。
在github上拉取代码后,首先需要先拉取第三方依赖,在项目目录下使用:
$ govendor sync
如果是DEMO代码,可以尝试本地跑该项目:
$ go run main.go
网友评论