在 Mac 的 Visual Studio Code 上装 Golang 的开发环境,在安装 go 的插件是,会自动更新依赖的库文件,由于各种原因,导致安装过程中,总是遇到插件安装失败的情况。
Go 的 SDK 安装
go 1.10 下载地址:
https://studygolang.com/dl
配置 GOPATH
查看 Go 的环境变量设置的命令
go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
需要设置的环境变量包括:GOPATH和PATH,GOROOT变量默认已经设置好。
在bash中设置:
vim .bash_profile
在 .bash_profile 设置
export GOPATH="/Users/username/go"
export PATH="/Users/username/go/bin:$PATH"
使修改立刻生效:
source .bash_profile
查看 Go 的环境变量
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/username/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT=""
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"