Skip to content

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

Closed
@amenzhinsky

Description

@amenzhinsky

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions