gpt4 book ai didi

linux - 为交叉编译设置 Go 时出错

转载 作者:IT王子 更新时间:2023-10-29 01:42:55 26 4
gpt4 key购买 nike

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

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

当它尝试构建 cmd 包时出现错误。它说不允许使用内部包。这是 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 , 并查看 blame View 表明这已由 commit 1338f32 介绍去 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/.

关于linux - 为交叉编译设置 Go 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27997708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com