Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/cmd/goimports: adds unexpected renamed imports #29520
Three mysterious problems here (running in GOPATH mode):
Like I said, mysterious (and really very annoying).
Pretty funny bug, I couldn't quite believe it so I had to look. I think this is partly new in my rewritten code and partly old.
The example hits two corner cases in the goimports logic. First, the code that collects missing references knows that lower-case identifiers can't be exported by a package, so it doesn't add them as things to look for -- but it does that after it has registered that it's looking for a package named f. Now it's looking for f, and it doesn't have to export anything.
So then it goes looking for 'f'. It finds a bunch of directories with the letter f in their name, of course, and then tries to load their exports. As it does that it tries to check the package statement of each file, and if it finds one that doesn't match, rejects the package as mismatched. But winfsnotify is for Windows, and all of its files are build tagged as such. So it never finds a package statement to check. Normally that wouldn't matter since it also didn't find anything exported. Here, though, it's good enough.
Both should be easy fixes.