建立交叉编译的错误。

时间:2023-01-26 21:47:48

I'm using Linux 64-bit and I'm trying to set up Go for cross-compiling (for Windows, specifically). There's an awesome guide for this here. But when I try to run the second command below:

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

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

I get errors when it tries to build the cmd package. It says use of internal package not allowed. Is this a bug in Go's main source code? I'll paste the full list of errors.

当它试图构建cmd包时,会出现错误。它表示不允许使用内部包。这是Go的主要源代码中的一个bug吗?我将粘贴错误的完整列表。

# 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

I can't find anything like this on Google, so that probably means I'm doing something wrong. I'm using Arch Linux, by the way, and I installed Go with pacman, not from source.

我在谷歌上找不到这样的东西,所以这可能意味着我做错了什么。顺便说一下,我用的是Arch Linux,我用的是Go,而不是source。

1 个解决方案

#1


2  

This error comes from cmd/go/pkg.go#L358, and a look at the blame view show this has been introduced by commit 1338f32 for go 1.4

这个错误来自cmd/go/pkg。go#L358,看一下blame视图,这是由commit 1338f32为go 1.4引入的

So the guide might work only with go 1.3-, not go 1.4, because of the Go 1.4 "Internal" Package proposition.

因此指南可能只适用于go 1.3—而不是go 1.4,因为go 1.4“内部”包主张。

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.

对于Go 1.4,我们将首先以$GOROOT实现规则,而不是$GOPATH。我们将使用编译器转换和标准库中的一些次要用途来获得使用规则的经验。

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/.

由于主repo的不规则性,作为特殊情况,$GOROOT/src/pkg/…路径中的“/pkg/”元素被认为不存在。这意味着美元GOROOT / src / pkg /内部可以通过美元进口GOROOT / src / cmd /…除了GOROOT美元/ src / pkg / ....当我们将标准库移动到$GOROOT/src/时,这个特殊情况将被删除。

#1


2  

This error comes from cmd/go/pkg.go#L358, and a look at the blame view show this has been introduced by commit 1338f32 for go 1.4

这个错误来自cmd/go/pkg。go#L358,看一下blame视图,这是由commit 1338f32为go 1.4引入的

So the guide might work only with go 1.3-, not go 1.4, because of the Go 1.4 "Internal" Package proposition.

因此指南可能只适用于go 1.3—而不是go 1.4,因为go 1.4“内部”包主张。

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.

对于Go 1.4,我们将首先以$GOROOT实现规则,而不是$GOPATH。我们将使用编译器转换和标准库中的一些次要用途来获得使用规则的经验。

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/.

由于主repo的不规则性,作为特殊情况,$GOROOT/src/pkg/…路径中的“/pkg/”元素被认为不存在。这意味着美元GOROOT / src / pkg /内部可以通过美元进口GOROOT / src / cmd /…除了GOROOT美元/ src / pkg / ....当我们将标准库移动到$GOROOT/src/时,这个特殊情况将被删除。