准备
安装依赖管理
brew install dep
安装dep同时也会安装依赖Go
- 配置环境变量
vim ~/.zshrc
# go
export GOPATH=$HOME/Workspace/go
export GOBIN=$HOME/Workspace/go/bin
export PATH=$PATH:$GOBIN
. ~/.zshrc
示例
mkdir -p ~/Workspace/go/src/gin-basic && cd ~/Workspace/go/src/gin-basic
dep init
curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go
dep ensure -add -v github.com/gin-gonic/gin@v1.3
go run main.go
curl localhost:8080/ping
# pong
关于Gin更多介绍可以参考gin-gonic/gin
参考
有疑问加站长微信联系(非本文作者)