'go install'找不到包“fmt”

时间:2016-12-05 15:06:37

标签: go

我安装了1.7.4,然后将其解压缩到〜/ go并相应地设置GOROOT。我还创建了〜/ work / src / github.com / user / hello并相应地设置了GOPATH。

https://golang.org/doc/install#testing尝试hello world示例时,我收到以下错误:

$ go install github.com/user/hello
    ../work/src/github.com/user/hello/hello.go:3:8: cannot find package "fmt" in any of:
    /home/user/go/src/pkg/fmt (from $GOROOT)
    /home/user/work/src/fmt (from $GOPATH)
package github.com/user/hello
    imports runtime: cannot find package "runtime" in any of:
    /home/user/go/src/pkg/runtime (from $GOROOT)
    /home/user/work/src/runtime (from $GOPATH)

检查〜/ go,我在〜/ go / src / fmt中找到fmt而不是〜/ go / src / pkg / fmt

感觉我错过了至关重要的事情。感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

对于MacPorts用户,例如去1.10.3安装,似乎没有为我正确安装。运行时标准包丢失。我什至尝试卸载并重新安装干净副本。所以我刚刚将其删除,并从Google获得了官方的darwin二进制软件包:

https://golang.org/dl/