设置 Go 进行交叉编译时出错

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


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

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


江户川乱折腾
浏览 344回答 1
1回答

温温酱

这个错误来自cmd/go/pkg.go#L358,查看一下blame视图显示这是由commit 1338f32为go 1.4引入的因此,由于Go 1.4“内部”包主张,该指南可能仅适用于 go 1.3-,而不适用于 go 1.4 。对于 Go 1.4,我们将首先为 实现规则$GOROOT,而不是$GOPATH。我们将使用编译器转换和标准库中的一些次要用途来获得规则的经验。由于主 repo 中的不规则性,作为特殊情况,路径中的“ /pkg/”元素$GOROOT/src/pkg/…被认为不存在。这意味着$GOROOT/src/pkg/internal可以通过进口$GOROOT/src/cmd/…除$GOROOT/src/pkg/…。当我们将标准库向上移动到$GOROOT/src/.
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go