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
Please answer these questions before submitting your issue. Thanks!
go version
tip
n/a
go env
darwin/amd64
build.Import() returns an error when trying to load a package from a module with version greater than 1.
build.Import()
cannot find package "github.com/foo/bar/v2" in any of: ...
I got to this indirectly through this:
import ( "go/ast" "go/importer" "go/types" ) func foo() { cfg := types.Config{ Importer: importer.For("source", nil), } _, err := cfg.Check(...) }
Where cfg.Check returned:
cfg.Check
could not import github.com/foo/bar/v2 (cannot find package "github.com/foo/bar/v2" in any of: ...
The go/* packages in the stdlib work the same way as vgo with the ability to load packages from versioned modules.
go/*
The errors listed above
The text was updated successfully, but these errors were encountered:
CC: @alandonovan @ianthehat @rsc
Sorry, something went wrong.
The answer is to use golang.org/x/tools/go/packages, under development now. If you find any problems using that package, please file new issues against it. Thanks very much.
I take it back - that's the long term answer but we can provide a short-term answer. I reopened this as #26504.
No branches or pull requests
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?tip
Does this issue reproduce with the latest release?
n/a
What operating system and processor architecture are you using (
go env
)?darwin/amd64
What did you do?
build.Import()
returns an error when trying to load a package from a module with version greater than 1.I got to this indirectly through this:
Where
cfg.Check
returned:What did you expect to see?
The
go/*
packages in the stdlib work the same way as vgo with the ability to load packages from versioned modules.What did you see instead?
The errors listed above
The text was updated successfully, but these errors were encountered: