使用 go1.21 开发,之前电脑有 1.19 版本
1.21 版本安装到了/Users/zhuxiaoyu/Desktop/go121 目录中
/etc/profile
```
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOPATH=/Users/zhuxiaoyu/Desktop/gopath
```
~/.bash_profile
```
export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOPATH=/Users/zhuxiaoyu/Desktop/gopath
export GOBIN=$GOPATH/bin
export PROTOBUF_HOME=/usr/local/protobuf
export GO111MODULE=auto
PATH=$PATH:$GOBIN:$PROTOBUF_HOME/bin
```
~/.zshrc
```
export GOPATH=/Users/zhuxiaoyu/Desktop/gopath
export GOROOT=/Users/zhuxiaoyu/Desktop/go121
export GOBIN=$GOPATH/bin
export PROTOBUF_HOME=/usr/local/protobuf
export GO111MODULE=on
export GETHBIN=/Users/zhuxiaoyu/Desktop/geth/build/bin
```
go env
```
GO111MODULE='auto'
GOARCH='amd64'
GOBIN='/Users/zhuxiaoyu/Desktop/gopath/bin'
GOCACHE='/Users/zhuxiaoyu/Library/Caches/go-build'
GOENV='/Users/zhuxiaoyu/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/zhuxiaoyu/Desktop/gopath/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/zhuxiaoyu/Desktop/gopath'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/zhuxiaoyu/Desktop/go121'
GOSUMDB=''
GOTMPDIR=''
GOTOOLCHAIN=''
GOTOOLDIR='/Users/zhuxiaoyu/Desktop/go121/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/ys/nth2j_v53q55rqfkhvdfnj_80000gn/T/go-build2234700829=/tmp/go-build -gno-record-gcc-switches -fno-common
```
vscode 的配置
```
"go.alternateTools": {
"go.goroot":"/Users/zhuxiaoyu/Desktop/go121",
"go.gopath":"/Users/zhuxiaoyu/Desktop/gopath"
}
```
vscode 报错提示
```
go: cannot find GOROOT directory: /Users/zhuxiaoyu/Desktop/gopath/go1.19.9
```
都快疯了,到底这个 vscode 读的哪里的环境变量 |
|