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

goimports removes imports that don't match package names #282

Closed
amenzhinsky opened this issue Nov 8, 2018 · 1 comment
Closed

goimports removes imports that don't match package names #282

amenzhinsky opened this issue Nov 8, 2018 · 1 comment

Comments

@amenzhinsky
Copy link

amenzhinsky commented Nov 8, 2018

Hi there!

It seems like that goimports fails to resolve imported packages if their paths don't match their names but the latest binary from the upstream doesn't do that.

Here's the script to reproduce it:

export GO111MODULE=on
echo 'module goimports' > go.mod
mkdir sub
echo 'package subpkg

func Foo() {}' > sub/sub.go
echo 'package main

import "goimports/sub"

func main() {
	subpkg.Foo()
}' > main.go

Run:

golangci-lint run --disable-all --enable=goimports

Output:

main.go:3: File is not `goimports`-ed (goimports)
import "goimports/sub"
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
@jirfag
Copy link
Contributor

jirfag commented Nov 10, 2018

hi! the fix is in the linked commit, thank you for reporting

jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70.

Also add tests for local mode of goimports and do refactoring of tests.
jirfag added a commit that referenced this issue Nov 10, 2018
ed64e33c8c8bc9a919e2b85a1a08225b5ae59d70. Also add tests
for local mode of goimports and do refactoring of tests.
@jirfag jirfag closed this as completed in ac77eaa Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants