Skip to content
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

x/tools/cmd/goimports: should not propose imports that are shadowed by vendored copies #23148

Open
timakin opened this issue Dec 15, 2017 · 3 comments
Labels
Milestone

Comments

@timakin
Copy link
Contributor

@timakin timakin commented Dec 15, 2017

When you format import sections, goimports help us out of kindness.
However, it mistakenly mix GOPATH-depended packages with packages under the vendor directory.

I expect it should exclude GOPATH-depended one from an import section. if I use any vendoring tool.

(It maybe the role of golint, so if you mind, cound you point out?)

@timakin
Copy link
Contributor Author

@timakin timakin commented Dec 15, 2017

$ tree $GOPATH
$GOPATH
└── src
    ├── foo
    │   ├── main.go
    │   └── vendor
    │       └── bar
    │           └── bar.go
    ├── bar
    │   └── bar.go
    └── baz
        └── baz.go
# foo/main.go
package main

import (
	"bar"
	"baz" # Should exclude this line cuz it couldn't be found under the `vendor` path.
)

func main() {
	baz.Baz(&bar.Bar{N: 100, S: "bar"})
}
@mvdan mvdan changed the title cmd/goimports: should exclude GOPATH-depended import if vendor/ is available x/tools/cmd/goimports: should exclude GOPATH-depended import if vendor/ is available Dec 15, 2017
@gopherbot gopherbot added this to the Unreleased milestone Dec 15, 2017
@heschi heschi changed the title x/tools/cmd/goimports: should exclude GOPATH-depended import if vendor/ is available x/tools/cmd/goimports: should not propose imports that are shadowed by vendored copies Nov 7, 2019
@heschi
Copy link
Contributor

@heschi heschi commented Nov 7, 2019

This seems like a real bug that could be fixed, but won't be an issue in module mode.

@vasilevp
Copy link

@vasilevp vasilevp commented Nov 22, 2019

There can still be vendor in module mode though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants