go: cmd/vet: inconsistent import

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
go version devel +d4ed8da Wed May 18 08:19:51 2016 +0000 linux/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/marko/goprojects"
GORACE=""
GOROOT="/home/marko/go"
GOTOOLDIR="/home/marko/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build502106107=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do? If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best.
I did go vet ./... to check my program.
  1. What did you expect to see?
Error or lack of error, but not panic.
  1. What did you see instead?
$ go vet ./...
panic: inconsistent import:
    var time.UTC *time.Location
previously imported as:
    var UTC *time.Location
 [recovered]
    panic: inconsistent import:
    var time.UTC *time.Location
previously imported as:
    var UTC *time.Location


goroutine 1 [running]:
panic(0x6428e0, 0xc4202d0d10)
    /home/marko/go/src/runtime/panic.go:500 +0x18c
go/types.(*Checker).handleBailout(0xc4200ba1c0, 0xc4200cb918)
    /home/marko/go/src/go/types/check.go:213 +0x95
panic(0x6428e0, 0xc4202d0d10)
    /home/marko/go/src/runtime/panic.go:458 +0x226
go/internal/gcimporter.(*importer).declare(0xc420096480, 0x7b71a0, 0xc4202e1c20)
    /home/marko/go/src/go/internal/gcimporter/bimport.go:173 +0x164
go/internal/gcimporter.(*importer).obj(0xc420096480, 0xfffffffffffffffc)
    /home/marko/go/src/go/internal/gcimporter/bimport.go:193 +0x191
go/internal/gcimporter.BImportData(0xc42000f080, 0xc420290000, 0x38ea0, 0x3fe00, 0xc42001395b, 0x4, 0x0, 0x4, 0x6bd3ac, 0xc41fff05ab)
    /home/marko/go/src/go/internal/gcimporter/bimport.go:86 +0x31e
go/internal/gcimporter.Import(0xc42000f080, 0xc42001395b, 0x4, 0x7ffd7a154e66, 0x14, 0xc42016d680, 0x0, 0x0)
    /home/marko/go/src/go/internal/gcimporter/gcimporter.go:166 +0x521
go/importer.gcimports.ImportFrom(0xc42000f080, 0xc42001395b, 0x4, 0x7ffd7a154e66, 0x14, 0x0, 0x4, 0x8, 0x0)
    /home/marko/go/src/go/importer/importer.go:70 +0x5a
go/types.(*Checker).collectObjects(0xc4200ba1c0)
    /home/marko/go/src/go/types/resolver.go:191 +0x7c8
go/types.(*Checker).checkFiles(0xc4200ba1c0, 0xc4200382d8, 0x1, 0x1, 0x0, 0x0)
    /home/marko/go/src/go/types/check.go:225 +0xa0
go/types.(*Checker).Files(0xc4200ba1c0, 0xc4200382d8, 0x1, 0x1, 0xc420174de0, 0x18)
    /home/marko/go/src/go/types/check.go:218 +0x3f
go/types.(*Config).Check(0xc420176940, 0xc4200138e8, 0x4, 0xc4200114c0, 0xc4200382d8, 0x1, 0x1, 0xc42016ceb0, 0x18, 0xc420173f80, ...)
    /home/marko/go/src/go/types/api.go:344 +0x184
main.(*Package).check(0xc4200188a0, 0xc4200114c0, 0xc4200382d8, 0x1, 0x1, 0xc4200382e0, 0x0)
    /home/marko/go/src/cmd/vet/types.go:76 +0x330
main.doPackage(0x69a65c, 0x1, 0xc42000a370, 0x1, 0x1, 0x0)
    /home/marko/go/src/cmd/vet/main.go:333 +0x956
main.main()
    /home/marko/go/src/cmd/vet/main.go:241 +0x317
exit status 2

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@griesemer nevermind, after cleaning my GOPATH the issue is gone. Thank you!

@dperny Thanks for the report. It may be possible to get this error when mixing packages using the old (textual) export format, and the new (binary) export format. The 1.7 compiler tries to be compatible to two export formats, and perhaps that’s not a good idea. Maybe it should just flat-out reject packages using the old format. Then users would simply be prompted to recompile their packages.

I have reproduced this off of a fresh upgrade from 1.6.2 to 1.7. I do not believe that I have ever had an RC installed; go was previously installed with homebrew, and was installed this time with the official installer.

I did mv pkg pkg.bak and then go vet works (with a new pkg generated). I removed the new pkg and added back the old one, and it fails again. I’m retaining a copy of the old pkg directory, if you’d like me to try some more probing, but for now the workaround of deleting pkg seems to work.

My error log is this:

🐳 vet
panic: inconsistent import:
        func github.com/docker/swarmkit/vendor/golang.org/x/net/context.WithValue(parent github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context, key interface{}, val interface{}) github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context
previously imported as:
        func github.com/docker/swarmkit/vendor/golang.org/x/net/context.WithValue(parent github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context, key interface{}, val interface{}) github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context
 [recovered]
        panic: inconsistent import:
        func github.com/docker/swarmkit/vendor/golang.org/x/net/context.WithValue(parent github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context, key interface{}, val interface{}) github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context
previously imported as:
        func github.com/docker/swarmkit/vendor/golang.org/x/net/context.WithValue(parent github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context, key interface{}, val interface{}) github.com/docker/swarmkit/vendor/golang.org/x/net/context.Context


goroutine 1 [running]:
panic(0x2734c0, 0xc4205a59d0)
        /usr/local/go/src/runtime/panic.go:500 +0x1a1
go/types.(*Checker).handleBailout(0xc4200ba1c0, 0xc420cfd8d8)
        /usr/local/go/src/go/types/check.go:213 +0xae
panic(0x2734c0, 0xc4205a59d0)
        /usr/local/go/src/runtime/panic.go:458 +0x243
go/internal/gcimporter.(*importer).declare(0xc4201c7110, 0x3f4180, 0xc420c536d0)
        /usr/local/go/src/go/internal/gcimporter/bimport.go:175 +0x17c
go/internal/gcimporter.(*importer).obj(0xc4201c7110, 0xfffffffffffffffb)
        /usr/local/go/src/go/internal/gcimporter/bimport.go:203 +0x4a2
go/internal/gcimporter.BImportData(0xc420014f60, 0xc420512000, 0xf3a7, 0xfe00, 0xc420cdc184, 0x3a, 0x0, 0x3a, 0x0, 0x287c20)
        /usr/local/go/src/go/internal/gcimporter/bimport.go:88 +0x390
go/internal/gcimporter.Import(0xc420014f60, 0xc42015a821, 0x18, 0x7fff5fbff8d0, 0x2, 0xc4204808c0, 0x0, 0x0)
        /usr/local/go/src/go/internal/gcimporter/gcimporter.go:166 +0x551
go/importer.gcimports.ImportFrom(0xc420014f60, 0xc42015a821, 0x18, 0x7fff5fbff8d0, 0x2, 0x0, 0xc420c25810, 0x0, 0x0)
        /usr/local/go/src/go/importer/importer.go:70 +0x67
go/types.(*Checker).collectObjects(0xc4200ba1c0)
        /usr/local/go/src/go/types/resolver.go:191 +0x826
go/types.(*Checker).checkFiles(0xc4200ba1c0, 0xc420208e40, 0x4, 0x4, 0x0, 0x0)
        /usr/local/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc4200ba1c0, 0xc420208e40, 0x4, 0x4, 0xc4201f3d10, 0xc4200cf960)
        /usr/local/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420216080, 0xc4200118f7, 0x7, 0xc4200138c0, 0xc420208e40, 0x4, 0x4, 0xc4201f5c70, 0x40, 0xc4200001a0, ...)
        /usr/local/go/src/go/types/api.go:344 +0x1a3
main.(*Package).check(0xc420016f00, 0xc4200138c0, 0xc420208e40, 0x4, 0x4, 0x0, 0xc4201c9680)
        /usr/local/go/src/cmd/vet/types.go:76 +0x370
main.doPackage(0x2cd6e4, 0x1, 0xc42000a1a0, 0x4, 0x4, 0x0, 0x1)
        /usr/local/go/src/cmd/vet/main.go:336 +0x999
main.main()
        /usr/local/go/src/cmd/vet/main.go:244 +0x345
exit status 2
make: *** [vet] Error 1

I also saw this after an upgrade to Go 1.7. It would be nice if the output mentioned the possibility of incompatible files in $GOPATH/pkg.