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/types: cannot import package with source code but no installed archive #12392

Closed
kr opened this issue Aug 28, 2015 · 2 comments
Closed

go/types: cannot import package with source code but no installed archive #12392

kr opened this issue Aug 28, 2015 · 2 comments

Comments

@kr
Copy link
Contributor

kr commented Aug 28, 2015

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

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

Expected output

package testdata ("testdata")
package testdata ("testdata")

Actual output

testdata/import.go:3:8: could not import p (can't find import: p)
package testdata ("testdata")
@griesemer
Copy link
Contributor

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.

@griesemer
Copy link
Contributor

Duplicate of #11415.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants