我试图像这样安装doozer:

$ goinstall github.com/ha/doozer

我得到这些错误。

goinstall: os: go/build: package could not be found locally goinstall: fmt: go/build: package could not be found locally goinstall: io: go/build: package could not be found locally goinstall: reflect: go/build: package could not be found locally goinstall: math: go/build: package could not be found locally goinstall: rand: go/build: package could not be found locally goinstall: url: go/build: package could not be found locally goinstall: net: go/build: package could not be found locally goinstall: sync: go/build: package could not be found locally goinstall: runtime: go/build: package could not be found locally goinstall: strings: go/build: package could not be found locally goinstall: sort: go/build: package could not be found locally goinstall: strconv: go/build: package could not be found locally goinstall: bytes: go/build: package could not be found locally goinstall: log: go/build: package could not be found locally goinstall: encoding/binary: go/build: package could not be found locally


当前回答

还有一种情况是,当我们使用go时,它会编译所有的go文件。

假设我们有一个文件main。然后我们将当前文件更改为main_old。Go,然后添加新的main。文件。然后当我们构建应用程序时,所有的go文件都将被编译。所以发生的错误可能是由于其他go文件中的编译错误。

其他回答

GOPATH的讨论如下:

GOPATH环境变量 GOPATH可以设置为一个以冒号分隔的路径列表,其中Go 可以找到代码、包对象和可执行文件。 设置GOPATH使用goinstall来构建和安装您自己的代码和 Go树之外的外部库(并避免写入 makefile)。

这里讨论的是GOROOT:

$GOROOT Go树的根,通常是$HOME/ Go。默认为 目录的父目录。Bash运行。如果你选择不去的话 设置$GOROOT时,必须运行gomake而不是make或gmake 使用传统的makefile开发Go程序。

如果你正在使用发行版go,你应该指向包含文件的位置,例如:

$ rpm -ql golang | grep include
/usr/lib/golang/include

(这是针对Fedora 20)

GOPATH不应该指向Go安装,而是指向您的工作空间(参见https://golang.org/doc/code.html#GOPATH)。当你使用go get或go install安装某个包时,它会落在GOPATH中。这就是为什么它警告你,你绝对不希望从互联网随机包被转储到你的正式安装。

值应该是(MACOS):

GOROOT="/usr/local/go" --> all binaries file core go
GOPATH="/Applications/proyectos/go" --> the route to workspace (custom workspace)

这里有一个解决方案(单用户):

GOROOT=$HOME/.local # your go executable is in $GOROOT/bin
GOPATH=$HOME/.gopath
PATH=$GOROOT/bin:$GOPATH/bin:$PATH

如果你把。gopath改成。Go, Go会报错。

我希望他们能像运货员那样,把所有东西都放在一个地方。