英文:
Errors setting up Go for cross-compiling
问题
我正在使用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
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
,而不是从源代码安装的。
英文:
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:
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.
# 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.
答案1
得分: 2
这个错误来自于cmd/go/pkg.go#L358
,查看责任视图可以看到这是由于提交 1338f32 引入的,针对 go 1.4。
所以这个指南可能只适用于 go 1.3 及以下版本,而不适用于 go 1.4,因为有关 Go 1.4 "Internal" Package 提议。
> 对于 Go 1.4,我们将首先为 $GOROOT
实现该规则,但不包括 $GOPATH
。我们将使用编译器转换和标准库中的一些次要用途来积累经验。
>
> 由于主存储库中的一个不规则性,作为一个特例,“/pkg/
”路径中的“/pkg/
”元素被认为不存在。
这意味着 $GOROOT/src/pkg/internal
可以被 $GOROOT/src/cmd/…
导入,除了 $GOROOT/src/pkg/…
。
当我们将标准库移到 $GOROOT/src/
时,这个特例将被移除。
英文:
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
So the guide might work only with go 1.3-, not go 1.4, because of the 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/
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论