You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've run into some behavior we didn't expect from go/types importing packages. If a package p has been imported (by some other package) and its source code is present but not installed (that is, there is no package archive such as $GOROOT/pkg/darwin_amd64/p.a) then Check returns an error saying it can't find the package.
We're not sure if this is intended behavior, but we found it surprising.
1. git clone https://github.com/kr/gotypesrepro $GOPATH/src/p
2. cd $GOPATH/src/p
3. go run try.go # fails
4. go install p
5. go run try.go # now it works
This is intended behavior and has been discussed before (e.g., #11415). The type checker purely type-checks a package for which the corresponding package file ASTs are provided. It doesn't know about the build environment, source code, etc. It relies on importers (go/importer) for imported packages. The currently installed importers only support gc or gccgo compiled packages. There is no "source importer" yet.
Go version 1.5
Summary
We've run into some behavior we didn't expect from go/types importing packages. If a package
p
has been imported (by some other package) and its source code is present but not installed (that is, there is no package archive such as$GOROOT/pkg/darwin_amd64/p.a
) then Check returns an error saying it can't find the package.We're not sure if this is intended behavior, but we found it surprising.
cc @tessr
We've tried to produce a minimal test case:
https://github.com/kr/gotypesrepro
Steps to reproduce
Expected output
Actual output
The text was updated successfully, but these errors were encountered: