aboutsummaryrefslogtreecommitdiff
path: root/refactor
diff options
context:
space:
mode:
Diffstat (limited to 'refactor')
-rw-r--r--refactor/rename/mvpkg.go6
-rw-r--r--refactor/rename/mvpkg_test.go6
2 files changed, 2 insertions, 10 deletions
diff --git a/refactor/rename/mvpkg.go b/refactor/rename/mvpkg.go
index 4d922f7..bf8edd6 100644
--- a/refactor/rename/mvpkg.go
+++ b/refactor/rename/mvpkg.go
@@ -26,7 +26,6 @@ import (
"runtime"
"strconv"
"strings"
- "sync"
"text/template"
"golang.org/x/tools/go/buildutil"
@@ -133,13 +132,12 @@ func srcDir(ctxt *build.Context, pkg string) (string, error) {
// subpackages returns the set of packages in the given srcDir whose
// import paths start with dir.
func subpackages(ctxt *build.Context, srcDir string, dir string) map[string]bool {
- var mu sync.Mutex
subs := map[string]bool{dir: true}
// Find all packages under srcDir whose import paths start with dir.
buildutil.ForEachPackage(ctxt, func(pkg string, err error) {
if err != nil {
- log.Fatalf("unexpected error in ForEackPackage: %v", err)
+ log.Fatalf("unexpected error in ForEachPackage: %v", err)
}
if !strings.HasPrefix(pkg, path.Join(dir, "")) {
@@ -157,9 +155,7 @@ func subpackages(ctxt *build.Context, srcDir string, dir string) map[string]bool
return
}
- mu.Lock()
subs[pkg] = true
- mu.Unlock()
})
return subs
diff --git a/refactor/rename/mvpkg_test.go b/refactor/rename/mvpkg_test.go
index b9f29d6..3c915b4 100644
--- a/refactor/rename/mvpkg_test.go
+++ b/refactor/rename/mvpkg_test.go
@@ -15,7 +15,6 @@ import (
"path/filepath"
"regexp"
"strings"
- "sync"
"testing"
"golang.org/x/tools/go/buildutil"
@@ -212,7 +211,6 @@ var _ a.T
for _, test := range tests {
ctxt := test.ctxt
- var mu sync.Mutex
got := make(map[string]string)
// Populate got with starting file set. rewriteFile and moveDirectory
// will mutate got to produce resulting file set.
@@ -225,19 +223,17 @@ var _ a.T
return
}
f, err := ctxt.OpenFile(path)
- defer f.Close()
if err != nil {
t.Errorf("unexpected error opening file: %s", err)
return
}
bytes, err := ioutil.ReadAll(f)
+ f.Close()
if err != nil {
t.Errorf("unexpected error reading file: %s", err)
return
}
- mu.Lock()
got[path] = string(bytes)
- defer mu.Unlock()
})
rewriteFile = func(fset *token.FileSet, f *ast.File, orig string) error {
var out bytes.Buffer