Ubuntu
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy,direct
注意:不要再按旧版本的介绍去创建和设置 GOPATH 目录
go version
go env
创建工程,安装依赖包
mkdir -p ~/my_project
cd ~/my_project
go mod init my_project
go get -u github.com/gin-gonic/gin
......
go run my.go
go build my.go
网友评论