-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: x/tools/go/packages: add no-network package lookup #40053
Comments
golang.org/x/tools/go/packages is the right one to be using, not go/build. |
I think this should be a feature of
#26717 is also a request for a general mechanism for exploring the module cache. |
@rsc thanks for pointing me in the right direction. @jayconrod go list is likely the right spot to implement a change. let me know if you need anything for this, including implementation work. |
Sounds like we need to decide how to tell the go command to do this, and then circle back to x/tools/go/packages. |
I talked to @jayconrod, @matloob, and @bcmills. The plan we suggest is to make |
I talked to @jayconrod, @matloob, and @bcmills again, and I also started a discussion on golang-tools about the right defaults for the go command. At this point, it seems like a likely outcome could be that the go command stops doing network lookups during go list by default, which would then make this proposal unnecessary - x/tools/go/packages would stop doing network lookups too. So we should probably wait until that gets resolved. Putting this proposal on hold. |
as a related note: part of the problem here is the lack of a well known API for interacting with dependency source code. (downloading, package directory locations/files) I had thought go/build was that but @rsc corrected me here. something to chew on for thought. |
@rsc bumping this =). its been quiet for awhile. and its unclear if goteam is considering this resolved with the go get / go install separation. I havent reviewed if those changes resolve my issues yet. |
@james-lawrence, did the change to default to |
believe it might have. lets consider this wrapped up then until I can prove otherwise =) my main concern was the network access and that change looks like it should have resolved it. |
I have a couple projects where I want to resolve the location of a package if it exists, but not retrieve/verify the package.
My initial attempts to use go/build.Context.Import trigger a retrieval of the package if its not found. which is undesirable due to both security and performance concerns.
I have no problem with that behavior, but go build and go install do not require network access and I'd prefer to not reinvent the wheel to locate packages that golang uses itself.
go/importer looked promising, but it suffers from the same issue as it uses go/build under the hood and it does not return the same information.
the underlying cause seems to be where Import shells out to go list to resolve the paths, though I stopped following the code once I hit the cmd execution in go/build.
Not opposed to implementing the changes myself, just looking for ideas/buyin/alternatives.
possible implementation ideas:
What version of Go are you using (
go version
)?go version go1.14.4 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
an error about package not found.
What did you see instead?
the package was downloaded and found.
The text was updated successfully, but these errors were encountered: