From 6e94e8a89f540122eaaf125fd43055d59fb22099 Mon Sep 17 00:00:00 2001 From: Ahmy Yulrizka Date: Sat, 19 Mar 2016 09:01:33 +0100 Subject: [PATCH] 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 Run-TryBot: Brad Fitzpatrick --- imports/fix.go | 2 +- imports/fix_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/imports/fix.go b/imports/fix.go index 4fc50570d7..1b0213743c 100644 --- a/imports/fix.go +++ b/imports/fix.go @@ -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 diff --git a/imports/fix_test.go b/imports/fix_test.go index a1cedf91f1..20c5b34ab5 100644 --- a/imports/fix_test.go +++ b/imports/fix_test.go @@ -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() {