Skip to content

x/tools/cmd/goimports: adds unexpected renamed imports #29520

@rsc

Description

@rsc

Three mysterious problems here (running in GOPATH mode):

$ go get -u golang.org/x/tools/cmd/goimports
$ echo 'package p; var _ = f.hash' | goimports
package p

import f "golang.org/x/exp/winfsnotify"

var _ = f.hash
$ 
  1. goimports should not be trying to find an import for f.hash at all.
    No import could possibly provide a lower-case name.
    goimports should not be wasting time scanning packages at all.

  2. Even if goimports were to look for a package,
    why on earth did it decide to import golang.org/x/exp/winfsnotify to f?
    (That package is package winfsnotify.)

  3. Even if goimports were to look for a package and rename it to f,
    why did it pick golang.org/x/exp/winfsnotify? That package does not
    contain the string hash anywhere in its sources.

Like I said, mysterious (and really very annoying).

/cc @heschik @ianthehat @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