美文网首页
gin简单demo构建

gin简单demo构建

作者: arthur25 | 来源:发表于2019-01-16 10:36 被阅读37次

go-gin构建

installation

To install Gin package, you need to install Go and set your Go workspace first.

  1. Download and install it:

    $ go get -u github.com/gin-gonic/gin

vendor tool

  1. go get govendor:

    $ go get github.com/kardianos/govendor

  2. Create your project folder and cd inside:

    $ mkdir -p $GOPATH/src/gin.com/gintest/ && cd "$_"

  3. Vendor init your project and add gin:

    $ govendor init

    $ govendor fetch github.com/gin-gonic/gin@v1.3

  4. Copy a starting template inside your project:

    $ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go

  5. 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

相关文章

网友评论

      本文标题:gin简单demo构建

      本文链接:https://www.haomeiwen.com/subject/utipdqtx.html