相关文档
下载安装过程参考菜鸟教程
咱的练习 练习项目
govender
go get govendor获取 将依赖包打包到项目目录下
cmd
govendor init
govendor add +local
govendor add +e配置国内镜像源
windows
bash
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,directlinux
bash
export GO111MODULE=on
export GOPROXY=https://goproxy.cn或者
bash
echo "export GO111MODULE=on" >> ~/.profile
echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
source ~/.profile其他镜像源
bash
阿里云: https://mirrors.aliyun.com/goproxy
微软: https://goproxy.io
七牛云: https://goproxy.cn
GoCenter: https://gocenter.io编译linux可执行文件
CGO_ENABLED=0 其中CGO_ENABLED=0的意思是使用C语言版本的GO编译器
cmd
SET CGO_ENABLED=0
set GOARCH=amd64
set GOOS=linux
go build编译windows可执行文件
cmd
SET CGO_ENABLED=0
set GOARCH=amd64
set GOOS=windows
go buildgo mod
go mod 是Golang 1.11 版本引入的官方包(package)依赖管理工具,用于解决之前没有地方记录依赖包具体版本的问题,方便依赖包的管理。 之前Golang 主要依靠vendor和GOPATH来管理依赖库,vendor相对主流,但现在官方更提倡go mod。 gomod使用帖子知乎上gomod使用帖子 生成go.mod文件
bash
go mod init下载并添加依赖到go.mod中
bash
go build
go test查看module下所有依赖
bash
go list -m all根据上面的操作列表信息更新依赖
bash
go get rsc.io/sampler@v1.2.0