Skip to content

x/tools/cmd/goimports: don't follow symlinks #45740

@adam-azarchs

Description

@adam-azarchs

What version of Go are you using (go version)?

$ go version
1.16.3

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/.../go-build"
GOENV="/.../.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="..."
GONOPROXY="..."
GONOSUMDB="..."
GOOS="linux"
GOPATH=".../gopath"
GOPRIVATE="..."
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/.../tools/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/.../go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="/.../bin/llvm-ar"
CC="/.../bin/clang"
CXX="/.../bin/clang++"
CGO_ENABLED="1"
GOMOD="/.../go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2861605680=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Used goimports on a file after having built with bazel.

What did you expect to see?

An import to abcxyz/package/name added to my file, relatively quickly.

What did you see instead?

An import to abcxyz/bazel-abcxyz/package/name added to my file, after a long time spent searching.

This is somewhat similar to the issue with e.g. node_modules (see for example #16417 or #30058) but the resolution seems a bit more clear in this case, at least to me: goimports should ignore symlinks the same way that go mod and go build do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions