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

go/build: Import seems to require absolute srcDir #14282

Open
griesemer opened this issue Feb 10, 2016 · 12 comments
Open

go/build: Import seems to require absolute srcDir #14282

griesemer opened this issue Feb 10, 2016 · 12 comments

Comments

@griesemer
Copy link
Contributor

While investigating go/types issue #14215, I noticed that (after fixing the obvious go/types bug), build.Import didn't find the desired package if srcDir was relative. Computing its absolute path (relative to cwd) fixed the problem.

Reminder to investigate behavior. Fix and/or document.

@griesemer griesemer added this to the Go1.7 milestone Feb 10, 2016
@griesemer
Copy link
Contributor Author

cc: @rsc

@griesemer
Copy link
Contributor Author

If build.Import is changed/fixed such that it accepts a relative srcDir we can undo the changes to FindPkg (computing of absolute srcDir) in the following CLs:

http://golang.org/cl/19393
http://golang.org/cl/19394

@ianlancetaylor ianlancetaylor changed the title build.Import seems to require absolute srcDir go/build: Import seems to require absolute srcDir May 16, 2016
@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
@quentinmit quentinmit added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 7, 2016
@rsc rsc modified the milestones: Go1.9Early, Go1.8 Oct 26, 2016
@griesemer
Copy link
Contributor Author

Another CL to update if this gets addressed: http://golang.org/cl/37405/

@griesemer
Copy link
Contributor Author

@rsc I'm going to assign this one to you (go/build issue); to decide and/or fix or document since you're most familiar with go/build.

I can take care of my CLs that contain the work-arounds.

@griesemer
Copy link
Contributor Author

If the solution turns out to be that build.Import creates an absolute path from a relative srcDir, build.Context may need to also export a new function field AbsPath func(path string) (string, error) (to match the other virtual file system support). By default (function is nil), filepath.Abs would be used instead. As is, libraries using a build.Context cannot handle the case correctly where srcDir is relative and build.Context provides customized file system functions because the libraries can't know how they should implement AbsPath. (see go/internal/srcimporter)

@bradfitz bradfitz modified the milestones: Go1.9, Go1.9Early May 3, 2017
@rsc rsc modified the milestones: Go1.10, Go1.9 Jun 12, 2017
@rsc
Copy link
Contributor

rsc commented Jun 15, 2017

I think we should fix it, for Go 1.10. Will send a CL.

@gopherbot
Copy link

CL https://golang.org/cl/45831 mentions this issue.

@rsc rsc added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jun 15, 2017
@rsc
Copy link
Contributor

rsc commented Nov 22, 2017

Decided to hold off. go/build is basically going to be deprecated for this kind of use in another release or two.

@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@dominikh
Copy link
Member

@rsc are there any written down plans on the package management changes, changes to go/build and so on that you have planned for future releases? This is probably something that tool authors want to know about way ahead of time.

@griesemer
Copy link
Contributor Author

Things are in flux with vgo coming down the pike. Pushing this to next release, and perhaps at some point we can just close it as not relevant anymore.

@griesemer
Copy link
Contributor Author

Moving to 1.13 where we may decide this doesn't matter anymore per #14282 (comment).

@griesemer griesemer modified the milestones: Go1.12, Go1.13 Oct 24, 2018
@griesemer griesemer modified the milestones: Go1.13, Go1.14 May 6, 2019
@griesemer griesemer added FrozenDueToAge and removed NeedsFix The path to resolution is known, but the work has not been done. labels Oct 1, 2019
@griesemer griesemer modified the milestones: Go1.14, Unplanned Oct 1, 2019
@griesemer
Copy link
Contributor Author

This has been "working" as is for > 3 years. With modules this code won't be executed anymore. It's unlikely that there is a need to fix this.

@rsc rsc unassigned rsc and griesemer Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
@bradfitz @dominikh @rsc @quentinmit @griesemer @gopherbot and others