Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
gotype: type-checking external test files that rely on internal test files fails #22030
I tried to use
I want to use the
I think the issue is that the
What version of Go are you using (
This is not a
The documentation inside
so this is at least working as internally documented. But it should be documented externally, and furthermore, this behavior seems incorrect. It appears that go test does something different.
This is not a trivial fix. An external test package imports the local package consisting of the local package and local test files. The go/command builds that package in a temporary directory and then imports it from that temporary directory to make it all work.
gotype relies on go/types to type-check the external test package. go/types simply uses an importer to get the information about the package to be tested, and that importer doesn't know that it needs that package built with its local test files. Furthermore, the existing top-level API (go/importer) doesn't have a mechanism to communicate that information. Also, if the importer is not a "source" importer, but say a "gc" importer, the importer relies on installed packages, and they are never built with the local test files.
One option might be to implement a new custom importer, only known to gotype.go, which is based on go/internal/srcimporter. The srcimporter's mode argument (currently unused) could be used to signal that local test files need to be included. But that would not work for