'go install'找不到包"fmt"

use*_*230 2 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)
Run Code Online (Sandbox Code Playgroud)

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

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

Ain*_*r-G 7

如果您之前从包管理器安装了Go,则可能是旧版本.go version如果需要,请检查并删除旧版本.