您的位置:首页 > 编程语言 > Go语言

[GO] mac cannot find package "fmt"

2017-08-05 23:01 495 查看
报错:

/usr/local/Cellar/go/1.8.3/libexec/bin/go build -i [/Users/xxxx]
httpServer.go:5:2: cannot find package "fmt" in any of:
/usr/local/bin/src/fmt (from $GOROOT)
/Users/haiqingzhu/go/src/fmt (from $GOPATH)
httpServer.go:6:2: cannot find package "log" in any of:
/usr/local/bin/src/log (from $GOROOT)
/Users/haiqingzhu/go/src/log (from $GOPATH)


原因:设置的GOROOT出现了错误。



GOROOT就是go的安装目录,而不是go bin的目录,默认给的就是这个目录,而在mac下使用brew安装的目录不是这个导致出现了错误,brew go的安装bin目录为:

/usr/local/Cellar/go/1.8.3/libexec/bin/go

此处使用: /usr/local/Cellar/go/1.8.3/libexec即可,如下:



可以继续玩耍了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  go mac