[GO] mac cannot find package "fmt"

xiaoxiao2021-02-28  114

报错:

/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即可,如下: 可以继续玩耍了。

转载请注明原文地址: https://www.6miu.com/read-39196.html

最新回复(0)