1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

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:
Ahmy Yulrizka 2016-03-19 09:01:33 +01:00 committed by Brad Fitzpatrick
parent fcde77432e
commit 6e94e8a89f
2 changed files with 5 additions and 5 deletions

View File

@ -171,7 +171,7 @@ type pkg struct {
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 {
sync.Mutex

View File

@ -803,7 +803,7 @@ func TestFindImportGoPath(t *testing.T) {
}
defer os.RemoveAll(goroot)
pkgIndexOnce = sync.Once{}
pkgIndexOnce = &sync.Once{}
origStdlib := stdlib
defer func() {
@ -858,7 +858,7 @@ type Buffer2 struct {}
}
func TestFindImportInternal(t *testing.T) {
pkgIndexOnce = sync.Once{}
pkgIndexOnce = &sync.Once{}
oldGOPATH := build.Default.GOPATH
build.Default.GOPATH = ""
defer func() {
@ -892,7 +892,7 @@ func TestFindImportInternal(t *testing.T) {
}
func TestFindImportVendor(t *testing.T) {
pkgIndexOnce = sync.Once{}
pkgIndexOnce = &sync.Once{}
oldGOPATH := build.Default.GOPATH
build.Default.GOPATH = ""
defer func() {
@ -926,7 +926,7 @@ func TestFindImportVendor(t *testing.T) {
}
func TestProcessVendor(t *testing.T) {
pkgIndexOnce = sync.Once{}
pkgIndexOnce = &sync.Once{}
oldGOPATH := build.Default.GOPATH
build.Default.GOPATH = ""
defer func() {