go环境
参考 https://www.cnblogs.com/liujitao79/p/8391398.html
安装dep
curl https://glide.sh/get | shor go get -u -v github.com/Masterminds/glide
新项目初始化
# cd $GOPROJECT/src# git clone https://github.com/liujitao/learning_go.git github.com/liujitao/learning_go# cd github.com/liujitao/learning_go# glide init
添加第三方依赖包
# glide get github.com/emicklei/go-restful#~2.8.0# glide get github.com/mattn/go-sqlite3
# cat glide.yamlpackage: .import:- package: github.com/emicklei/go-restful version: ~2.8.0- package: github.com/mattn/go-sqlite3 version: ~1.9.0
其他命令
USAGE: glide [global options] command [command options] [arguments...]VERSION: v0.13.1COMMANDS: create, init Initialize a new project, creating a glide.yaml file config-wizard, cw Wizard that makes optional suggestions to improve config in a glide.yaml file. get Install one or more packages into `vendor/` and add dependency to glide.yaml. remove, rm Remove a package from the glide.yaml file, and regenerate the lock file. import Import files from other dependency management systems. name Print the name of this project. novendor, nv List all non-vendor paths in a directory. rebuild Rebuild ('go build') the dependencies install, i Install a project's dependencies update, up Update a project's dependencies tree (Deprecated) Tree prints the dependencies of this project as a tree. list List prints all dependencies that the present code references. info Info prints information about this project cache-clear, cc Clears the Glide cache. about Learn about Glide mirror Manage mirrors help, h Shows a list of commands or help for one command
对于被墙的站点使用镜像
原版不支持下层路径# glide mirror set https://golang.org/x/net https://github.com/golang/net.git --vcs git[INFO] No mirrors.yaml file exists. Creating new one[INFO] https://golang.org/x/net being set to https://github.com/golang/net.git[INFO] mirrors.yaml written with changes# glide mirror set https://golang.org/x/sys https://github.com/golang/sys.git --vcs git[INFO] https://golang.org/x/sys being set to https://github.com/golang/sys.git[INFO] mirrors.yaml written with changes需使用 https://github.com/xkeyideal/glide.git 这个hack版本go get -u -v github.com/xkeyideal/glide go install -u -v github.com/xkeyideal/glide # glide mirror set https://golang.org/x/net/websocket https://github.com/golang/net.git --base golang.org/x/net# glide mirror set https://golang.org/x/sys/unix https://github.com/golang/sys.git --base golang.org/x/sys
posted on 2018-07-10 10:47 阅读( ...) 评论( ...)