当我 brew 安装好后配置 GOROOT、GOPATH、GOBIN 后执行一个简易的包
执行命令如下:
```bash
➜ pwd
/Users/just008/Code/Go/calc/bin
➜ echo $GOPATH
/Users/just008/Code/Go/calc
➜ go build calc
can't load package: package calc is not in GOROOT (/usr/local/Cellar/go/1.14.2_1/libexec/src/calc)
```
zsh 配置如下
```bash
export GOPATH=$$HOME/Code/Go:/HOME/Code/Go/calc:$HOME/Code/Go/learning
export GOROOT=/usr/local/opt/go/libexec
export GOBIN=$GOROOT/bin
export PATH="$GOBIN:$PATH"
```
怎么执行都报错:
`can't load package: package calc is not in GOROOT (/usr/local/Cellar/go/1.14.2_1/libexec/src/calc)`
当我把版本回退到 1.11 时就可以了。。
zsh 配置
```bash
export GOPATH=$$HOME/Code/Go:/HOME/Code/Go/calc:$HOME/Code/Go/learning
export GOROOT=/usr/local/opt/go@1.11/libexec
export GOBIN=$GOROOT/bin
export PATH="$GOBIN:$PATH"
```
这是什么问题呢??谷歌了也没找到。**难道我不配用新版本???**
#### 问题已解决
加入 `export GO111MODULE=off` 到 zshrc 中就可以了
有疑问加站长微信联系(非本文作者))