go/buildutil: rename AllPackages{,List} -> {ForEachPackage,AllPackages}.

This CL is the first refactoring automated by "gorename". :)
Though I had to update the comments and run 'hg gofmt'.   :(

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/142930043
This commit is contained in:
Alan Donovan 2014-09-11 14:33:37 -04:00
parent 78aabae27e
commit 66176e290c
6 changed files with 10 additions and 10 deletions

View File

@ -16,7 +16,7 @@ import (
"sync" "sync"
) )
// AllPackagesList returns the import path of each Go package in any source // AllPackages returns the import path of each Go package in any source
// directory of the specified build context (e.g. $GOROOT or an element // directory of the specified build context (e.g. $GOROOT or an element
// of $GOPATH). Errors are ignored. The results are sorted. // of $GOPATH). Errors are ignored. The results are sorted.
// //
@ -26,10 +26,10 @@ import (
// All I/O is via the build.Context virtual file system, // All I/O is via the build.Context virtual file system,
// which must be concurrency-safe. // which must be concurrency-safe.
// //
func AllPackagesList(ctxt *build.Context) []string { func AllPackages(ctxt *build.Context) []string {
var list []string var list []string
var mu sync.Mutex var mu sync.Mutex
AllPackages(ctxt, func(pkg string, _ error) { ForEachPackage(ctxt, func(pkg string, _ error) {
mu.Lock() mu.Lock()
list = append(list, pkg) list = append(list, pkg)
mu.Unlock() mu.Unlock()
@ -38,7 +38,7 @@ func AllPackagesList(ctxt *build.Context) []string {
return list return list
} }
// AllPackages calls the found function with the import path of // ForEachPackage calls the found function with the import path of
// each Go package it finds in any source directory of the specified // each Go package it finds in any source directory of the specified
// build context (e.g. $GOROOT or an element of $GOPATH). // build context (e.g. $GOROOT or an element of $GOPATH).
// //
@ -48,7 +48,7 @@ func AllPackagesList(ctxt *build.Context) []string {
// The found function and the build.Context virtual file system // The found function and the build.Context virtual file system
// accessors must be concurrency safe. // accessors must be concurrency safe.
// //
func AllPackages(ctxt *build.Context, found func(importPath string, err error)) { func ForEachPackage(ctxt *build.Context, found func(importPath string, err error)) {
var wg sync.WaitGroup var wg sync.WaitGroup
for _, root := range ctxt.SrcDirs() { for _, root := range ctxt.SrcDirs() {
root := root root := root

View File

@ -12,7 +12,7 @@ import (
) )
func TestAllPackages(t *testing.T) { func TestAllPackages(t *testing.T) {
all := buildutil.AllPackagesList(&build.Default) all := buildutil.AllPackages(&build.Default)
set := make(map[string]bool) set := make(map[string]bool)
for _, pkg := range all { for _, pkg := range all {

View File

@ -39,7 +39,7 @@ func TestStdlib(t *testing.T) {
ctxt := build.Default // copy ctxt := build.Default // copy
ctxt.GOPATH = "" // disable GOPATH ctxt.GOPATH = "" // disable GOPATH
conf := loader.Config{Build: &ctxt} conf := loader.Config{Build: &ctxt}
for _, path := range buildutil.AllPackagesList(conf.Build) { for _, path := range buildutil.AllPackages(conf.Build) {
if err := conf.ImportWithTests(path); err != nil { if err := conf.ImportWithTests(path); err != nil {
t.Error(err) t.Error(err)
} }

View File

@ -39,7 +39,7 @@ func TestStdlib(t *testing.T) {
SourceImports: true, SourceImports: true,
Build: &ctxt, Build: &ctxt,
} }
if _, err := conf.FromArgs(buildutil.AllPackagesList(conf.Build), true); err != nil { if _, err := conf.FromArgs(buildutil.AllPackages(conf.Build), true); err != nil {
t.Errorf("FromArgs failed: %v", err) t.Errorf("FromArgs failed: %v", err)
return return
} }

View File

@ -33,7 +33,7 @@ func TestStdlib(t *testing.T) {
SourceImports: true, SourceImports: true,
Build: &ctxt, Build: &ctxt,
} }
if _, err := conf.FromArgs(buildutil.AllPackagesList(conf.Build), true); err != nil { if _, err := conf.FromArgs(buildutil.AllPackages(conf.Build), true); err != nil {
t.Errorf("FromArgs failed: %v", err) t.Errorf("FromArgs failed: %v", err)
return return
} }

View File

@ -88,7 +88,7 @@ func Build(ctxt *build.Context) (forward, reverse Graph, errors map[string]error
}() }()
var wg sync.WaitGroup var wg sync.WaitGroup
buildutil.AllPackages(ctxt, func(path string, err error) { buildutil.ForEachPackage(ctxt, func(path string, err error) {
if err != nil { if err != nil {
errorc <- pathError{path, err} errorc <- pathError{path, err}
return return