-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/gotype: -a flag doesn't include XTestGoFiles #18799
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
Comments
The XTestGoFiles define a different package from the GoFiles and TestGoFiles. gotype would have to run the type-checker a second time to process these files. The best way to do that is to use the golang.org/x/tools/go/loader package, but it seems out of scope for an undocumented diagnostic tool such as gotype. cc: @griesemer |
|
On 6 February 2017 at 15:23, Josh Bleecher Snyder ***@***.***> wrote:
gotype may be an undocumented diagnostic tool, but it seems many people
(myself included) use it when they want a fast answer to the question "does
this typecheck?", which is not an uncommon question.
You could try using ssadump for that purpose; it does the right thing for
XTestGoFiles, and it also understands cgo.
I'll leave it up to Robert to decide what, if anything, to do about gotype.
|
@myitcv gotype is not taking into account package-external test files. As is, it can't easily do so because it requires the package to be tested to be installed first (which may not be the case). This is because external test files are not part of the package, they are a separate package. This is related to #11415 . Without that, we cannot easily fix this one. I'm not saying gotype shouldn't or couldn't do what you are suggesting, but the existing behavior is not a bug, it's intended. Changed to unplanned. This is not urgent. If anybody wants to look into it, that's fine, but it's not going to be simple without #11415 (which is planned for 1.9). |
@alandonovan @griesemer thanks for the comments, helped steer me in the right direction.
@josharian don't know about your use case, but I need
In my case I know this will be the case. I have a little helper that aggressively ensures all transitive dependencies (test included) of a "package spec of interest" are So what I might do for now is fork tools and modify
...
Totally agree. Thanks both for taking the time to comment in any case. |
@griesemer I've just mailed https://go-review.googlesource.com/#/c/36992/ Not a perfect fix I agree given your comments about #11415, but perhaps it suffices for now? |
CL https://golang.org/cl/36992 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
What did you see instead?
Nothing
If instead we change to use the package name:
then the output is as expected.
Is the intention that
gotype
be consistent withcmd/go
's definition of Go files? Should therefore XTestGoFiles be considered along withTestGoFiles
?Happy to help contribute if you think this is the right fix.
cc @alandonovan
The text was updated successfully, but these errors were encountered: