-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/goimports: incorrectly assumes module cache directory paths match module paths #29550
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
(How do I run the repro? I'm slightly familiar with the test script language, but this thing where it's split into three files is new to me.) Even without running the repro I think I understand what's happening. When doing a Nasty bug. I'm not sure how to fix it. In this particular case, @bcmills, @jayconrod, is there any chance that with -e this could be in the JSON rather than a fatal error? |
I'm just writing a simple rig for running arbitrary testscript tests (with goproxytest mod files).
Isn't the logic you want here to only add a directory (for which the directory path does not equal the module path) if that directory is "in use" as the target of a replace, else don't add such mismatched directories? |
PS this bug is now killing me because my module cache contains a number of such replace targets where the directory path does not match the module path. |
Yeah. That's what I meant by manually parsing the module file and skipping mismatches. Sigh. I guess I can copy cmd/go/internal/modfile and its deps into x/tools. I'll try to get to this early next week after I've talked with @ianthehat. If it's convenient, pushing the repro to GitHub would save me a little time -- I need something |
@heschik - apologies, haven't had a chance to look at this yet. Just to also flag,
It should be possible to get what we need from these |
Good point on encoding. I'm afraid plans have changed and I've got some other goimports work to do so this fix will be delayed. But I'll get to it as part of that work or ASAP afterward. |
Note that there is an existing function in |
Yes, that's arguably what it ought to do. Might not be feasible until 1.13, though. |
I updated @subash-a's description of this issue to include a fully reproducible script. |
@heschik - as promised, here's a repro of the related path encoding bug:
which should pass but gives:
|
Thanks for the repros. Both of them pass with https://golang.org/cl/158097, and I believe the test cases I copied from cmd/go cover these cases. |
That CL is submitted, so this should be fixed. Let me know if not. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes the issue is reproducible with the latest version of go (
go1.12beta1
)What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The following
testscript
script reproduces the issue:What did you expect to see?
A successful run (the
stdout main.go
check should succeed becausemain.go
is missing an import to satisfy the qualified identifiercore.
).What did you see instead?
Our main module includes a
replace
directive; therefore our module cache contains a directory structure where the path does not match the contained module's path (the directory$GOPATH/pkg/mod/github.com/user/banana@v1.0.0
contains the modulefruit.com@v1.0.0
).goimports
appears to assume that directories within the module cache contain modules with the same path (which results in the above error message). But with replacements that will not be the case.cc @heschik @bradfitz @ianthehat @myitcv
The text was updated successfully, but these errors were encountered: