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

Gopkgs stops working if Go gets upgraded #7

Open
Vizualni opened this issue Jul 1, 2019 · 0 comments
Open

Gopkgs stops working if Go gets upgraded #7

Vizualni opened this issue Jul 1, 2019 · 0 comments

Comments

@Vizualni
Copy link

Vizualni commented Jul 1, 2019

Every couple of months I notice that gopkgs stops listing Go's packages such as "time", "os", "net/http" and others.

I think that I was able to pinpoint why that thing happens. Inside the codebase, there are usages of the build.Default.GOROOT (from go/build package):

isGoroot := srcDir == filepath.Join(build.Default.GOROOT, "src")

If the host machine does not have the GOROOT env. variable set (it's not a requirement to be set), then it uses values that are written to the binary file itself. Those values may be different if compiled on different host machines or if you use homebrew and upgrade the Go to a different version.

To test this theory I've written a small program that displays the build's default context.

package main

import "fmt"
import "go/build"

func main() {
	fmt.Printf("%+v\n", build.Default)
}

I've built the same program on two different hosts with two different Go versions installed. One is the Linux machine (inside of a docker container) and the other one is my host machine which is the macOS 10.13.3.

I've built the from_linux binary inside of a Docker container for the macOS, then I run it from the macOS. I've also built the same binary on the host machine itself.

Running both binaries locally, it's visible that GOROOT is different.

Screen Shot 2019-07-01 at 14 42 50

The same thing happens when you are using homebrew to upgrade go. If you built the gopkgs on version Go version 1.11.11 and then upgrade Go to version 1.12.6, it will not list any of those Go related packages because the folder does not exist anymore. It was deleted by the homebrew. This is what happens to me every few months.


And of course, setting the GOROOT env variable fixes the problem:

Screen Shot 2019-07-01 at 14 45 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant