MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

go: GOROOT is hardcoded (and wrong)

Open elieux opened this issue 9 years ago • 7 comments

There is a variable, GOROOT, that specifies where go should look for its files. If not set in environment, go uses a hardcoded path defined at build-time (which for current binaries is C:\repo\mingw-w64-go\src\go).

We need to define GOROOT in profile.d (which is probably bad, because it's a mingw package) or patch the source, so go finds the path relatively to its executable.

elieux avatar Jan 12 '15 16:01 elieux

Need more work on relocating go folders. Right now it not usable at all. It still look into ${GOROOT}/src instead ${GOROOT}/lib/go/src

Alexpux avatar Jul 26 '15 17:07 Alexpux

For reference: the Go Language manual Getting Started (doc/install) recommends never to install Go in other path than the installer suggests. Currently, BTW, GOROOT variable is always hardcoded into the binaries when Go is built. In Windows it's in pkg/windows_amd64/runtime/cgo.a now.

$GOROOT is widely used in every platform, while it's assumed to be hardcoded as the installer suggests. And it does not seem to change in the future. So I don't even think writing a patch is possible.

Despite not recommended by the language maintainers, it's enough to set $GOROOT for equivalent of $MINGW_PREFIX/lib/go; i.e. run GOROOT=/mingw64/lib/go go env or GOROOT=$MINGW_PREFIX/lib/go go env instead of go env. So if possible, the package need to contain only one more line of setting GOROOT variable when installed.

eonj avatar Dec 11 '16 20:12 eonj

@elieux Is this issue still reproducible?

Biswa96 avatar Oct 16 '22 13:10 Biswa96