[GO] mac cannot find package "fmt"

报错:

/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出现了错误。
[GO] mac cannot find package
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 cannot find package
可以继续玩耍了。

你可能感兴趣的:(golang)