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

Prepend path separator to GOROOT prefix when checking for stdlib packages #13

Closed
wants to merge 1 commit into from

Conversation

nkubala
Copy link

@nkubala nkubala commented Dec 10, 2019

previously, this code was simply checking if the build.Default.GOROOT was a prefix of the target package path to see if the package was from the stdlib. this was failing for me, as the default GOROOT /usr/local/go was being used (since I don't have one set), but all of my packages lived under /usr/local/google/....

sadly, there's no better solution in the filepath package to check if a path is nested under another path.

@googlebot googlebot added the cla: yes Contributor license agreement signed (https://cla.developers.google.com) label Dec 10, 2019
@RJPercival
Copy link
Contributor

Could you add a test case for this please?

@RJPercival
Copy link
Contributor

It sounds like this is deceptively hard to do right: golang/go#18358

I suspect this change might cause a bug if the user does define $GOROOT and includes a trailing slash. Perhaps using filepath.Clean() on both paths would fix this? I'd like to see some test cases to get some confidence that this is an improvement.

@AlCutter AlCutter closed this May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Contributor license agreement signed (https://cla.developers.google.com)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants