Skip to content

testing: Reuse of exported var name when using . import panics #10942

@anacrolix

Description

@anacrolix

In examples_test.go:

package torrent_test
import torrent "."

In the the rest of the go files in the directory:

package torrent

anacrolix@Matts-MBP:~/gopath/src/github.com/anacrolix/torrent$ go test .
2015/05/24 21:27:41 expvar.go:254: Reuse of exported var name: unusedDownloadedChunksCount
panic: Reuse of exported var name: unusedDownloadedChunksCount

goroutine 1 [running]:
log.Panicln(0xc20804bee8, 0x2, 0x2)
/Users/anacrolix/src/go/src/log/log.go:334 +0xc4
expvar.Publish(0x46139d0, 0x1b, 0x4979770, 0xc20800b4b0)
/Users/anacrolix/src/go/src/expvar/expvar.go:254 +0x236
expvar.NewInt(0x46139d0, 0x1b, 0x4831ec8)
/Users/anacrolix/src/go/src/expvar/expvar.go:272 +0x78
_/Users/anacrolix/gopath/src/github.com/anacrolix/torrent.init()
/Users/anacrolix/gopath/src/github.com/anacrolix/torrent/client.go:46 +0x112
github.com/anacrolix/torrent_test.init()
/Users/anacrolix/gopath/src/github.com/anacrolix/torrent/example_test.go:18 +0x47
main.init()
github.com/anacrolix/torrent/_test/_testmain.go:102 +0x56

The "." import seems to cause expvar to init those variables twice?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions