2

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.

GreenRaccoon23
  • 3,603
  • 7
  • 32
  • 46

1 Answers1

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

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

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So is it not possible to setup cross-compilation on Arch Linux with Go 1.4? Or is there some workaround? – m01 Jun 20 '15 at 22:31
  • 2
    @m01 not that I know of. Go 1.5 will make cross-compilation dead-simple though: http://stackoverflow.com/a/28829037/6309, and https://github.com/golang/go/wiki/GoTalks#go-in-go, like https://talks.golang.org/2015/gogo.slide#18, using goos and goarch presented in http://stackoverflow.com/a/30068222/6309. – VonC Jun 21 '15 at 04:59
  • Ok - sounds like my options are: go back to Go 1.3, go forward to the dev version of Go 1.5, or wait for Go 1.5 to be released. Thanks! – m01 Jun 22 '15 at 09:47
  • 1
    @m01 I agree. Go 1.5 will be released in August, so in 2 months or so. – VonC Jun 22 '15 at 10:49
  • Since I've run in to this many times, I thought I'd add my workaround for using 1.4: Move `$GOROOT/src/cmd/cmd/pprof` to `$GOPATH/src/cmd/cmd/pprof` and everything should compile fine. – xthexder Aug 03 '15 at 16:57