../../../go/pkg/mod/github.com/micro/go-micro@v1.16.0/server/rpc_server.go:8:2: package runtime/debug is not in GOROOT (/usr/local/opt/go@1.14/src/runtime/debug)
../../../go/pkg/mod/github.com/micro/go-micro@v1.16.0/debug/profile/pprof/pprof.go:8:2: package runtime/pprof is not in GOROOT (/usr/local/opt/go@1.14/src/runtime/pprof)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/app.go:9:2: package sort is not in GOROOT (/usr/local/opt/go@1.14/src/sort)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/flag.go:8:2: package strconv is not in GOROOT (/usr/local/opt/go@1.14/src/strconv)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/command.go:7:2: package strings is not in GOROOT (/usr/local/opt/go@1.14/src/strings)
../../../go/pkg/mod/github.com/google/uuid@v1.3.0/node.go:8:2: package sync is not in GOROOT (/usr/local/opt/go@1.14/src/sync)
../../../go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/filedesc/desc.go:11:2: package sync/atomic is not in GOROOT (/usr/local/opt/go@1.14/src/sync/atomic)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/context.go:8:2: package syscall is not in GOROOT (/usr/local/opt/go@1.14/src/syscall)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/help.go:8:2: package text/tabwriter is not in GOROOT (/usr/local/opt/go@1.14/src/text/tabwriter)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/help.go:9:2: package text/template is not in GOROOT (/usr/local/opt/go@1.14/src/text/template)
../../../go/pkg/mod/github.com/micro/cli@v0.2.0/app.go:10:2: package time is not in GOROOT (/usr/local/opt/go@1.14/src/time)
../../../go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/strs/strings.go:11:2: package unicode is not in GOROOT (/usr/local/opt/go@1.14/src/unicode)
../../../go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/encoding/text/decode_string.go:12:2: package unicode/utf16 is not in GOROOT (/usr/local/opt/go@1.14/src/unicode/utf16)
../../../go/pkg/mod/google.golang.org/protobuf@v1.27.1/internal/strs/strings.go:12:2: package unicode/utf8 is not in GOROOT (/usr/local/opt/go@1.14/src/unicode/utf8)
../../../go/pkg/mod/google.golang.org/protobuf@v1.27.1/reflect/protoreflect/value_unsafe.go:10:2: cannot find package "unsafe" in any of:
/usr/local/opt/go@1.14/src/unsafe (from $GOROOT)
更换go 版本的时候遇到问题,如上面的的报错。
原因回溯:
Mac 环境
原来是安装的最新版本的 go1.17.3
后来又使用 brew install go@1.14
~/.zshrc
查询版本报错:
% go version
go: cannot find GOROOT directory: /usr/local/opt/go@1.14/1.14.15/libexec
配置
export PATH="/usr/local/opt/go@1.14/1.14.15/bin:$PATH"
export GOROOT=/usr/local/opt/go@1.14/1.14.15/libexec
export GO111MODULE=on
运行下面命令。
% brew link go@1.14 --force
Linking /usr/local/Cellar/go@1.14/1.14.15... 3 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/go@1.14/bin:$PATH"' >> ~/.zshrc
.zshrc 或者 .bash_profile中 去掉 GOROOT=/usr/local/opt/go@1.14/1.14.15/libexec 配置也可以
export GO111MODULE=on
export PATH="/usr/local/opt/go@1.14/bin:$PATH"
在安装完后,使用 % brew link go@1.14 --force 命令切换就正常了