imports: cleanup test due to assignment copies of sync.Once
go vet detected that the value of pkgIndexOnce is copied through assignments in the test. This patch fixes that by converting it to *sync.Once instead. Change-Id: I90b2252942625b2f8a93eb5da24d16c6a8a56e4e Reviewed-on: https://go-review.googlesource.com/20910 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
fcde77432e
commit
6e94e8a89f
|
@ -171,7 +171,7 @@ type pkg struct {
|
||||||
dir string // absolute file path to pkg directory e.g. "/usr/lib/go/src/fmt"
|
dir string // absolute file path to pkg directory e.g. "/usr/lib/go/src/fmt"
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkgIndexOnce sync.Once
|
var pkgIndexOnce = &sync.Once{}
|
||||||
|
|
||||||
var pkgIndex struct {
|
var pkgIndex struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
|
@ -803,7 +803,7 @@ func TestFindImportGoPath(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(goroot)
|
defer os.RemoveAll(goroot)
|
||||||
|
|
||||||
pkgIndexOnce = sync.Once{}
|
pkgIndexOnce = &sync.Once{}
|
||||||
|
|
||||||
origStdlib := stdlib
|
origStdlib := stdlib
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -858,7 +858,7 @@ type Buffer2 struct {}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindImportInternal(t *testing.T) {
|
func TestFindImportInternal(t *testing.T) {
|
||||||
pkgIndexOnce = sync.Once{}
|
pkgIndexOnce = &sync.Once{}
|
||||||
oldGOPATH := build.Default.GOPATH
|
oldGOPATH := build.Default.GOPATH
|
||||||
build.Default.GOPATH = ""
|
build.Default.GOPATH = ""
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -892,7 +892,7 @@ func TestFindImportInternal(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindImportVendor(t *testing.T) {
|
func TestFindImportVendor(t *testing.T) {
|
||||||
pkgIndexOnce = sync.Once{}
|
pkgIndexOnce = &sync.Once{}
|
||||||
oldGOPATH := build.Default.GOPATH
|
oldGOPATH := build.Default.GOPATH
|
||||||
build.Default.GOPATH = ""
|
build.Default.GOPATH = ""
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -926,7 +926,7 @@ func TestFindImportVendor(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProcessVendor(t *testing.T) {
|
func TestProcessVendor(t *testing.T) {
|
||||||
pkgIndexOnce = sync.Once{}
|
pkgIndexOnce = &sync.Once{}
|
||||||
oldGOPATH := build.Default.GOPATH
|
oldGOPATH := build.Default.GOPATH
|
||||||
build.Default.GOPATH = ""
|
build.Default.GOPATH = ""
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
Loading…
Reference in New Issue