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

cmd/vet: panics with inconsistent import #16112

gyuho opened this issue Jun 19, 2016 · 4 comments

cmd/vet: panics with inconsistent import #16112

gyuho opened this issue Jun 19, 2016 · 4 comments


Copy link

@gyuho gyuho commented Jun 19, 2016

I think I found a strange edge case for go vet.

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

go version devel +691c5c1 Sun Jun 19 05:18:09 2016 +0000 linux/amd64

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

go env
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build259744847=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Here are my file structure:

~/go/src/ $ find .
// 1.go
package aaa

import ""

type WAL struct {
    lockedFiles []*fileutil.LockedFile
// 2.go
package aaa

import "time"

const (
    warnSyncDuration = time.Second
// fileutil/fileutil.go
package fileutil

import "os"

type LockedFile struct {

And I just ran go vet *.go in ~/go/src/

What did you expect to see?

It shouldn't panic.

What did you see instead?

go vet *.go

panic: inconsistent import:
    var time.UTC *time.Location
previously imported as:
    var UTC *time.Location
    panic: inconsistent import:
    var time.UTC *time.Location
previously imported as:
    var UTC *time.Location

goroutine 1 [running]:
panic(0x662f00, 0xc4201e8420)
    /home/gyuho/go-master/src/runtime/panic.go:500 +0x1a1
go/types.(*Checker).handleBailout(0xc4200a61c0, 0xc4200b98e8)
    /home/gyuho/go-master/src/go/types/check.go:213 +0xae
panic(0x662f00, 0xc4201e8420)
    /home/gyuho/go-master/src/runtime/panic.go:458 +0x243
go/internal/gcimporter.(*importer).declare(0xc42007e480, 0x7de1e0, 0xc4201e7bd0)
    /home/gyuho/go-master/src/go/internal/gcimporter/bimport.go:173 +0x17c
go/internal/gcimporter.(*importer).obj(0xc42007e480, 0xfffffffffffffffc)
    /home/gyuho/go-master/src/go/internal/gcimporter/bimport.go:193 +0x1af
go/internal/gcimporter.BImportData(0xc42000b110, 0xc4201a0000, 0x39d34, 0x3fe00, 0xc42001199b, 0x4, 0x0, 0x4, 0x10, 0x10)
    /home/gyuho/go-master/src/go/internal/gcimporter/bimport.go:86 +0x34c
go/internal/gcimporter.Import(0xc42000b110, 0xc42001199b, 0x4, 0x6bba44, 0x1, 0xc42014c3c0, 0x0, 0x0)
    /home/gyuho/go-master/src/go/internal/gcimporter/gcimporter.go:166 +0x551
go/importer.gcimports.ImportFrom(0xc42000b110, 0xc42001199b, 0x4, 0x6bba44, 0x1, 0x0, 0x1, 0x2, 0x0)
    /home/gyuho/go-master/src/go/importer/importer.go:70 +0x67
    /home/gyuho/go-master/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc4200a61c0, 0xc420011a30, 0x2, 0x2, 0x0, 0x0)
    /home/gyuho/go-master/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc4200a61c0, 0xc420011a30, 0x2, 0x2, 0xc42013ede0, 0xc4200b9960)
    /home/gyuho/go-master/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420015440, 0xc4200118b0, 0x3, 0xc420015240, 0xc420011a30, 0x2, 0x2, 0xc420141860, 0x20, 0xc4200001a0, ...)
    /home/gyuho/go-master/src/go/types/api.go:344 +0x19f
main.(*Package).check(0xc4200608a0, 0xc420015240, 0xc420011a30, 0x2, 0x2, 0xc420011a40, 0x1)
    /home/gyuho/go-master/src/cmd/vet/types.go:76 +0x36c
main.doPackage(0x6bba44, 0x1, 0xc42000a3d0, 0x2, 0x2, 0x0)
    /home/gyuho/go-master/src/cmd/vet/main.go:333 +0x992
    /home/gyuho/go-master/src/cmd/vet/main.go:241 +0x335
exit status 2

Could anyone take a look? Or am I doing something wrong?

It's weird. If I put all the code in one file (without 2.go) in top aaa package, I don't see this panic.


Copy link

@ALTree ALTree commented Jun 19, 2016

Bisected to CL 22123, so cc @griesemer I guess.

Copy link

@ianlancetaylor ianlancetaylor commented Jun 20, 2016

I can't recreate the problem. I don't see any warnings or panics from vet.

Does it get fixed if you run go install?

@ianlancetaylor ianlancetaylor added this to the Go1.7Maybe milestone Jun 20, 2016
@ianlancetaylor ianlancetaylor changed the title vet: panics with time.Second cmd/vet: panics with inconsistent import Jun 20, 2016
Copy link
Contributor Author

@gyuho gyuho commented Jun 20, 2016

It's weird. It's not happening in my local machine either. I still keep the same go version. Guess my machine had cached something in tmp directory that might have caused this.

Please feel free to close it.

When I can reliably reproduce, I will revisit this issue.


Copy link

@josharian josharian commented Jun 20, 2016

OK. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.