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/types: cannot locate transient dependency saved via Go modules #27556
Comments
With Go modules, you need to use There is more discussion about I can't really say this is "working as intended", but I'm going to close the issue in any case. Please feel free to join us in golang-tools in case you have any queries about the use of |
@myitcv How stable would you say |
That warning is more relevant to pre the Go 1.11 release (cc @matloob - any update required here?).
Hence that warning should probably be read as "please start using and road testing go/packages, on the understanding we might make minor API changes". @ianthehat's team is responsible for |
We will probably be changing the warning soon, at this point its more along the lines of: the API is fairly stable, we will be trying hard not to break it without a really good reason, and we would prefer if you are using it you come talk to us in golang-tools in case we do need to break it so we can let you know. We are not yet ready to promise it's fully stable, we need to be able to make changes when we find a tool that really needs something it cannot support. |
What version of Go are you using (
go version
)?go version go1.11 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
1. Ensure a clean slate.
Steps 2 and 3 set up a fresh Go development environment on a new Linux server for maximum reproducibility (I spun up a new CentOS server on Vultr). Alternatively, delete
${GOPATH}/pkg
and${GOPATH}/src/golang.org/x/text
if they exist.2. Install the latest Go:
3. Create a new user and set them up for Go development:
4. Create a new project outside of GOPATH.
I created a new
workspace
directory, and inside that addedapp/app.go
:I then ran the following to enable Go modules and install its dependency:
The
app
folder now contains 3 files:app.go
,go.mod
, andgo.sum
, all with the expected contents. Of note is the fact thatgo.mod
does not contain a direct reference togolang.org/x/text/unicode/norm
, but instead its parent package:Running
go build
ensures that everything works, and indeed we can see the dependency stored at~/go/pkg/mod/golang.org/x/text\@v0.3.0/
.5. Use
go/types
to type-check it.I wrote a small program that uses the
go/types
package to typecheck a program: https://play.golang.org/p/5wWtuNqYv1n, which should be saved in~/workspace
.What did you expect to see?
Given that the program builds fine, I would expect to see no errors when type-checking it.
What did you see instead?
The program fails with the following error:
In addition, using
importer.Default()
instead results in an even simpler error:The text was updated successfully, but these errors were encountered: