Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golang-1.10 GOROOT requires manual export on Ubuntu Xenial #25421

Closed
hollowaykeanho opened this issue May 16, 2018 · 7 comments
Closed

Golang-1.10 GOROOT requires manual export on Ubuntu Xenial #25421

hollowaykeanho opened this issue May 16, 2018 · 7 comments

Comments

@hollowaykeanho
Copy link

What version of Go are you using (go version)?

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/home/holloway/bin"
GOCACHE="/home/holloway/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/holloway"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build607283709=/tmp/go-build -gno-record-gcc-switches"

Ubuntu Xenial (Vanila)

http://ppa.launchpad.net/gophers/archive/ubuntu xenial main

What did you do?

$ sudo add-apt-repository ppa:gophers/archive
$ sudo apt update -y
$ sudo apt install golang-1.10 -y
$ export PATH="/usr/lib/go-1.10/bin:$PATH"
$ vi <a poor go source code> # save it and let go metalinter to perform validation

securekey_test.go|6 col 2 warning| unused struct field could not import testing (cannot find package "testing" in any of: (structcheck)                         
securekey_test.go|34 col 4 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Errorf (structcheck)
securekey_test.go|38 col 3 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Logf (structcheck)
securekey_test.go|6 col 2 warning| unused variable or constant could not import testing (cannot find package "testing" in any of: (varcheck)
securekey_test.go|41 col 4 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Errorf (structcheck)
securekey_test.go|34 col 4 warning| unused variable or constant invalid operation: t (variable of type *invalid type) has no field or method Errorf (varcheck)
securekey_test.go|66 col 3 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Logf (structcheck)
securekey_test.go|38 col 3 warning| unused variable or constant invalid operation: t (variable of type *invalid type) has no field or method Logf (varcheck)
securekey_test.go|72 col 4 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Errorf (structcheck)
securekey_test.go|41 col 4 warning| unused variable or constant invalid operation: t (variable of type *invalid type) has no field or method Errorf (varcheck)
securekey_test.go|95 col 3 warning| unused struct field invalid operation: t (variable of type *invalid type) has no field or method Logf (structcheck)

$ export GOROOT="/usr/lib/go-1.10"
$ export PATH="$GOROOT/bin:$PATH"
$ vi <the same poor go source code> # save it to let go metalinter to perform validation
# no more error

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
Follow all the $ commands in the above

What did you expect to see?

Go 1.10 is setup correctly, with GOROOT properly exported after installation. User only need to set GOPATH, GOBIN etc.

What did you see instead?

Need to set and export GOROOT explicitly to ensure the the standard packages are found.

@agnivade
Copy link
Contributor

This is an issue with the debian package itself. Go distributions expect they will be installed in /usr/local/go. For other locations like /usr/lib/go-1.10, you have to set it up yourself.

From the docs - https://golang.org/doc/install

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.

@davecheney
Copy link
Contributor

davecheney commented May 16, 2018 via email

@hollowaykeanho
Copy link
Author

@davecheney, noted. Appreciate if this ticket to be reopened until I've transfer the ticket to launchpad please?

I'll close the ticket once the transfer is completed. NOTE: I'm not the only person facing the issue.

@hollowaykeanho
Copy link
Author

hollowaykeanho commented May 19, 2018

After working with Michael Hudson-Doyle, the ppa maintainer. We found that this issue is completely not related to the deb package.

  1. the metalinter issue was caused by the metalinter package itself, and it requires alecthomas/gometalinter@0725fc6 which was committed 11 days ago from this post. Updating the metalinter package with that commit will solve the issue.

  2. Unknown issue with go get -u. I'm no longer be able to reproduce the issue with go get update after performing a mass packages update go get -u $GOPATH/src/..., including the metalinter problem above.

Since the guide in https://github.com/golang/go/wiki/Ubuntu only spells how to install but not on how to update, I'll list the notes here in case any ubuntu user wants to update their golang in the future.

$ sudo apt update -y
$ sudo apt remove golang1.X # old version
$ sudo apt install golang1.Y # new version
$ export PATH="/usr/lib/go-1.Y/bin:$PATH"  # to get go and gofmt into your bin list
$ export GOROOT="/usr/lib/go-1.Y" # temporary for mass update.
$ go get -u "$GOPATH/src/..." # update all packages

This should prevent any future metalinter or linter issue that cause this problem at the first place.
Restart your terminal without the export GOROOT. Your new go should be fine.

@davecheney
Copy link
Contributor

davecheney commented May 19, 2018 via email

@hollowaykeanho
Copy link
Author

@davecheney, the export listed here is meant for problem No. 2, and for other 3rd party packages carrying the same issue like metalinter did (until they fix the problem).

I'm currently using go without needing to export GOROOT after the mass update, AFAIK, from deb packaging standpoint, the go package is installed correctly with the custom path. I agree to you, that you don't need to export GOROOT explicitly.

However, I disagree not to export GOROOT temporarily before the mass updates because that's assuming all 3rd party tool packages are not repeating what metalinter did.

@dolmen
Copy link
Contributor

dolmen commented Jul 6, 2018

I wonder if you have 2 different versions of Go and a mismatch between GOPATH and GOROOT.
The report should mention the output of the following commands before and after installing golang-1.10:

go env GOROOT
which go

@golang golang locked and limited conversation to collaborators Jul 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants