为交叉编译设置 Go 时出错

Errors setting up Go for cross-compiling

我正在使用 Linux 64 位,我正在尝试设置 Go 进行交叉编译(特别是 Windows)。 here 有一个很棒的指南。但是当我尝试 运行 下面的第二个命令时:

cd /usr/lib/go/src
sudo GOOS=windows GOARCH=386 CGO_ENABLED=0 ./make.bash --no-clean

我在尝试构建 cmd 包时遇到错误。它说 use of internal package not allowed。这是 Go 主要源代码中的错误吗?我将粘贴完整的错误列表。

# Building packages and commands for host, linux/amd64.
package cmd/cmd/pprof
    imports cmd/pprof/internal/driver: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/fetch: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/symbolizer: use of internal package not allowed
package cmd/cmd/pprof
    imports cmd/pprof/internal/symbolz: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/report: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/svg: use of internal package not allowed
package cmd/cmd/pprof/internal/commands
    imports cmd/pprof/internal/tempfile: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/commands: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/report: use of internal package not allowed
package cmd/cmd/pprof/internal/driver
    imports cmd/pprof/internal/tempfile: use of internal package not allowed
package cmd/cmd/pprof/internal/fetch
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/fetch
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/plugin
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/report
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/report
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolizer
    imports cmd/pprof/internal/plugin: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolizer
    imports cmd/pprof/internal/profile: use of internal package not allowed
package cmd/cmd/pprof/internal/symbolz
    imports cmd/pprof/internal/profile: use of internal package not allowed

我在 Google 上找不到类似的内容,所以这可能意味着我做错了什么。顺便说一下,我正在使用 Arch Linux,并且我使用 pacman 安装了 Go,而不是从源代码安装的。

此错误来自 cmd/go/pkg.go#L358, and a look at the blame view show this has been introduced by commit 1338f32 for go 1.4

因此该指南可能仅适用于 go 1.3-,不适用于 go 1.4,因为 Go 1.4 "Internal" Package proposition.

For Go 1.4, we will implement the rule first for $GOROOT, but not $GOPATH. We will use the compiler conversion and some minor uses in the standard library to gain experience with the rule.

Due to an irregularity in the main repo, as a special case, the “/pkg/” element in $GOROOT/src/pkg/… paths is considered not to exist.
This means that $GOROOT/src/pkg/internal can be imported by $GOROOT/src/cmd/… in addition to $GOROOT/src/pkg/….
This special case will be removed when we move the standard library up to $GOROOT/src/.