Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/goimports: goimports removes used import, breaks build #28645

Closed
dcelasun opened this issue Nov 7, 2018 · 2 comments
Closed

x/tools/cmd/goimports: goimports removes used import, breaks build #28645

dcelasun opened this issue Nov 7, 2018 · 2 comments

Comments

@dcelasun
Copy link

dcelasun commented Nov 7, 2018

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

$ go version
go version go1.11.1 linux/amd64

goimports from 34b416b.

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
GOARCH="amd64"
GOBIN="/home/dcelasun/go/bin"
GOCACHE="/home/dcelasun/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dcelasun/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build196516147=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ git clone https://github.com/dcelasun/importbug.git $GOPATH/src/github.com/dcelasun/importbug
$ cd $GOPATH/src/github.com/dcelasun/importbug
$ go get -u golang.org/x/tools/cmd/goimports
$ goimports -l -w main.go
$ go build

See: https://github.com/dcelasun/importbug

What did you expect to see?

Successfully build the program.

What did you see instead?

$ go build
# github.com/dcelasun/importbug
./main.go:8:14: undefined: fb

because goimports removed the github.com/dcelasun/importbug/go-foobar import.

@gopherbot gopherbot added this to the Unreleased milestone Nov 7, 2018
@heschi
Copy link
Contributor

heschi commented Nov 7, 2018

This would be golang/tools@864069c. Giving the import an explicit name will keep it from being removed but it's a bad user experience. I'll roll back while I think about it.

@heschi
Copy link
Contributor

heschi commented Nov 7, 2018

Fixed in golang/tools@a28dfb4.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants