diff --git a/imports/fix.go b/imports/fix.go index 4fc50570..1b021374 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 a1cedf91..20c5b34a 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() {