Skip to content

x/tools/cmd/goimports: incorrect removal of imports #29557

@rsc

Description

@rsc

In GOPATH mode:

$ rm -rf $GOPATH/src/gopkg.in/russross/blackfriday.v2
$ echo 'package p; import "gopkg.in/russross/blackfriday.v2"; var _ blackfriday.Node' | goimports
package p

var _ blackfriday.Node
$ 

Apparently because the package does not exist locally, goimports can't find out its package name, so goimports decides to remove the import entirely! This is incorrect and should not happen.

Goimports should never remove an import statement for a package that it simply cannot find.

/cc @heschik @bradfitz

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions