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: Report package name != base src directory #23184
go version go1.9.2 darwin/amd64
Using imported package
and package file
This silent removing confuses a lot (again a new colleague/Go newbie stumbled upon this). That's why
What did you expect to see?
An error on
and a flag
I think it should be a part of
would mean that
What did you see instead?
We're not adding a flag.
I'm pretty sure goimports already correctly handles this case, and we have tests for it too.
I suspect that goimports is unable to scan your $GOPATH so it's unable to learn that
Fix your permission error and then let's see what happens.
Couldn't figure out yet why there's a
Anyway, I worked around the
However, these lines don't seem enough that an IDE can (easily) act on to show the deletion reason at the former line
Sidenote: The 3 lines above don't show up if you use the imported package correctly, e.g. like this:
Full output (from
Those lines are for people debugging goimports while developing goimports. They're not for users or IDEs.
It looks like everything is happening properly: when you don't use the import it's removed, and when you do use it, it's not removed.
You want to get warnings, but goimports isn't in the business of warnings.
That is probably the job of a lint tool, as it's more of a style issue.
I'm going to close this, as I see nothing for goimports to do. Let me know if I misunderstand, though.