Skip to content

x/tools/cmd/goimports: error "root package %s is missing" #29297

@thatguystone

Description

@thatguystone

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

$ go version
go version go1.11.4 linux/amd64

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=""
GOCACHE="~/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="~/Dev/go"
GOPROXY=""
GORACE=""
GOROOT="~/.gimme/versions/go1.11.4.linux.amd64"
GOTMPDIR=""
GOTOOLDIR="~/.gimme/versions/go1.11.4.linux.amd64/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="~/Desktop/test/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build909428892=/tmp/go-build -gno-record-gcc-switches"

What did you do?

~ $ git clone git@gist.github.com:0ce7246431ace4c03a7ae82400ed9050.git
Cloning into '0ce7246431ace4c03a7ae82400ed9050'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.
~ $ cd 0ce7246431ace4c03a7ae82400ed9050/
0ce7246431ace4c03a7ae82400ed9050 $ goimports -w .
root package strings is missing

What did you expect to see?

goimports should do nothing. If I rm go.mod, it works correctly (in that it doesn't report an error).

What did you see instead?

goimports prints "root package strings is missing" and exits with status 2.

This seems to be a bug introduced from @heschik's fix for #27287.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions