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

Libraries are ignored when goroot and gopath share the same prefix #38

Closed
dbaumgarten opened this issue Aug 28, 2020 · 0 comments · Fixed by #148
Closed

Libraries are ignored when goroot and gopath share the same prefix #38

dbaumgarten opened this issue Aug 28, 2020 · 0 comments · Fixed by #148
Labels
help wanted Extra attention is needed

Comments

@dbaumgarten
Copy link

dbaumgarten commented Aug 28, 2020

If your go-root is (for example) /home/ubuntu/go and your gopath is /home/ubuntu/gopath, go-licenses will treat all dependencies as stdlib and therefore ignore them.

The issue lies here: https://github.com/google/go-licenses/blob/master/licenses/library.go#L204
When packages are stored inside the gopath, their path will start with /home/ubuntu/gopath, and as /home/ubuntu/go is a prefix of this, go-licenses thinks these packages belong to the stdlib.

The solution would be to append a path-seperator to build.Default.GOROOT (if it does not already end in one) before performing the prefix-check.

@Bobgy Bobgy added the help wanted Extra attention is needed label Apr 11, 2022
@Bobgy Bobgy changed the title Libraries are ignored when gopath is poorly chosen Libraries are ignored when goroot and gopath share the same prefix Sep 14, 2022
jingyuanliang added a commit to jingyuanliang/go-licenses that referenced this issue Sep 14, 2022
jingyuanliang added a commit to jingyuanliang/go-licenses that referenced this issue Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants