FS#38597 - [go] $GOROOT is not needed
Attached to Project:
Community Packages
Opened by Pierre Durand (Pierrre) - Tuesday, 21 January 2014, 10:56 GMT
Last edited by Alexander F. Rødseth (xyproto) - Wednesday, 26 February 2014, 16:19 GMT
Opened by Pierre Durand (Pierrre) - Tuesday, 21 January 2014, 10:56 GMT
Last edited by Alexander F. Rødseth (xyproto) - Wednesday, 26 February 2014, 16:19 GMT
|
Details
Description:
http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really The environment variable $GOROOT is not needed (defined in /etc/profile.d/go.sh) |
This task depends upon
Closed by Alexander F. Rødseth (xyproto)
Wednesday, 26 February 2014, 16:19 GMT
Reason for closing: Fixed
Additional comments about closing: GOROOT is not set by the go package. This was fixed. The re-opening seems to be "not a bug".
Wednesday, 26 February 2014, 16:19 GMT
Reason for closing: Fixed
Additional comments about closing: GOROOT is not set by the go package. This was fixed. The re-opening seems to be "not a bug".
I have the "tip" version installed (for test), and I must unset GOROOT in order to make it work.
$ godoc io
2014/02/13 03:47:46 open /usr/local/go/src/pkg/io: no such file or directory
After having receieved pointers to this link in the past (http://dave.cheney.net/2013/06/14/you-dont-need-to-set-goroot-really) together with requests for removing the GOROOT setting, I'm surprised that it should be set by the go package. I'm currently asking #go-nuts what they think. So far one person thinks that GOROOT_FINAL is should be set instead. I'll investigate some more.
What does
which godoc
and
pacman -Qo `which godoc`
say?
there is a special case https://code.google.com/p/go/source/browse/src/cmd/go/pkg.go?name=release-branch.go1.2#312
It's installed in $GOROOT_FINAL/bin instead of $GOPATH/bin
godoc -goroot="/usr/lib/go"
I have not installed godoc manually.
/usr/bin/godoc
$ pacman -Qo `which godoc`
/usr/bin/godoc is owned by go 2:1.2-2
I will re-add GOROOT and see if it makes godoc work again.
"export GOROOT_FINAL=/usr/lib/go" (in PKGBUILD) should work.
Reportedly, godoc worked when GOROOT was still set in /etc/profile.d/go.sh.
If this is a problem with godoc or not, I don't know, but if adding GOROOT solves a problem and has no negative consequences, not adding GOROOT back would be curious choice.
If I compile Go with GOROOT=/tmp I get this at the end of the build:
"The binaries expect /home/pierre/Logiciels/go to be copied or moved to /tmp"
You use a pre compiled Go (http://go.googlecode.com/files/go1.2.linux-amd64.tar.gz)
I think GOROOT_FINAL is only useful/usable if you build Go from source! :)
Are there objections to adding /etc/profile.d/go.sh back to the go package, so that it sets GOROOT, so that godoc starts working again?
I wish to make sure the go package is packaged as correctly as possible, but if a good default setting can fix a commonly used tool, I think it's a worthwhile trade-off.
http://golang.org/doc/install
"Installing to a custom location"
The Go binary distributions assume they will be installed in /usr/local/go (or c:\Go under Windows), but it is possible to install the Go tools to a different location. In this case you must set the GOROOT environment variable to point to the directory in which it was installed.
For example, if you installed Go to your home directory you should add the following commands to $HOME/.profile:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
Note: GOROOT must be set only when installing to a custom location.
Actually, if you want to really build the package from source, you need to clone https://code.google.com/p/go
http://golang.org/doc/install/source
But by all means, fetching the code with mercurial, from the correct release tag, may be a favorable approach.
In any case, the documentation you linked to seems clear to me. When go is not installed in /usr/local (not normally used by Arch Linux packages), GOROOT should be set.
Are you sure the "godoc" binary is built when you run make.bash?
I think it's not compiled, and you use the precompiled binary.
If you run make.bash form the precompiled go distribution, godoc is NOT build! :)
GOROOT_FINAL is not used for godoc.
Steps:
- download and extract go 1.2 precompiled distribution
- remove binaries in "bin" (go, gofmt, godoc)
- run "./make.bash" in "src"
- only go and gofmt are built in "bin"
https://code.google.com/p/go/source/browse/src/cmd/go/pkg.go?name=go1.2#299
There is a special case when you run "go get code.google.com/p/go.tools/cmd/godoc".
It is installed in GOROOT/bin instead of GOPATH/bin.
cover and vet tools are installed in GOROOT/pkg/tool
You must embed this tools it the "go" archlinux package, because the user can't install them in GOROOT_FINAL (owned by the root user)
Building from the mercurial sources seems to work fine. I'm currently trying to find the right place to put "go get" for the various needed tools (and find the correct environment variables).
When you use "go get", binaries are installed in $GOPATH/bin (except vet, cover and godoc).
I think GOARCH is not needed in PKGBUILD (I don't use it when I compile Go from source, or install libraries).
You should use "any" for the package's arch.
(I've successfully built Go on ArchLinux ARM)
Since this issue is about GOROOT, and it has been concluded that it indeed does not need to be set (the problem was with godoc), and since the current go package does not set GOROOT, I'll just close this issue.