Skip to content

x/tools/cmd/goimports: weird behaviours - not importing and removing dependencies automatically #34518

@brunoluiz

Description

@brunoluiz

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

$ go version
go version go1.13 darwin/amd64

Does this issue reproduce with the latest release?

Yes, it does

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/brunoluiz/Library/Caches/go-build"
GOENV="/Users/brunoluiz/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/brunoluiz/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/brunoluiz/git/snapdiff/scheduler/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=/var/folders/46/73767m017_n8yfc849p52zpm0000gn/T/go-build095282659=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Using goimports -w file.go or through vim-go.

What did you expect to see?

Dependencies (external or internal) should be auto imported.

What did you see instead?

It doesn't auto-import packages from the same project/module, it doesn't fetch external packages and sometimes, even if I add import statements manually it scrapes it. Example: I am using strconv.itoa and even if I add strconv to imports statement, goimports removes it.

I thought initially it was a vim-go issue, but I've tried goimports -w file.go and it doesn't as expected.

Side note: if I run go get ..., it doesn't scrape the dependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions