安装go
- 下载源码包:wget https://dl.google.com/go/go1.17.2.linux-amd64.tar.gz
在/usr/local下解压源码包:sudo tar -zxf go1.17.2.linux-amd64.tar.gz -C /usr/local
配置环境变量
由于我使用的shell是 zsh,就以 zsh 为例:
进入 zsh 配置文件:vi ~/.zshrc
- 添加字段:
export GOROOT=/usr/local/go
export GOPATH=~/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
-
配置代理
env -w GOPROXY=https://goproxy.cn,direct
vscode 配置
安装 vscode go 插件;
- 安装 go tools,建议直接使用 go get,使用的 tools 列表如下:
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/mdempsky/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/zmb3/gogetdoc
go get -u -v golang.org/x/lint/golint
go get -u -v github.com/fatih/gomodifytags
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/goimports
go get -u -v github.com/cweill/gotests/...
go get -u -v golang.org/x/tools/cmd/guru
go get -u -v github.com/josharian/impl
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
可以开始愉快的写 go 程序了。