mac上直接用homebrew安装的go,在执行go get github.com/smartystreets/goconvey
的时候报了以下错误
➜ demoProject go get github.com/smartystreets/goconvey
package embed: unrecognized import path "embed": import path does not begin with hostname
package io/fs: unrecognized import path "io/fs": import path does not begin with hostname
➜ demoProject
go env
检查go环境设置
➜ ~ go env
// 省略
GOPATH="/Users/xxx/go"
// 省略
➜ ~
问题在于我本地没有这个路径,我实际的go安装路径是/usr/local/Cellar/go@1.13
修改GOPATH:vim .bash_profile
加上go配置
export GOPATH=/usr/local/Cellar/go@1.13 // 你本地的go路径
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
使修改立即生效source .bash_profile
Done.
网友评论