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:
parent
78aabae27e
commit
66176e290c
|
@ -16,7 +16,7 @@ import (
|
|||
"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
|
||||
// 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,
|
||||
// which must be concurrency-safe.
|
||||
//
|
||||
func AllPackagesList(ctxt *build.Context) []string {
|
||||
func AllPackages(ctxt *build.Context) []string {
|
||||
var list []string
|
||||
var mu sync.Mutex
|
||||
AllPackages(ctxt, func(pkg string, _ error) {
|
||||
ForEachPackage(ctxt, func(pkg string, _ error) {
|
||||
mu.Lock()
|
||||
list = append(list, pkg)
|
||||
mu.Unlock()
|
||||
|
@ -38,7 +38,7 @@ func AllPackagesList(ctxt *build.Context) []string {
|
|||
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
|
||||
// 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
|
||||
// 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
|
||||
for _, root := range ctxt.SrcDirs() {
|
||||
root := root
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAllPackages(t *testing.T) {
|
||||
all := buildutil.AllPackagesList(&build.Default)
|
||||
all := buildutil.AllPackages(&build.Default)
|
||||
|
||||
set := make(map[string]bool)
|
||||
for _, pkg := range all {
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestStdlib(t *testing.T) {
|
|||
ctxt := build.Default // copy
|
||||
ctxt.GOPATH = "" // disable GOPATH
|
||||
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 {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestStdlib(t *testing.T) {
|
|||
SourceImports: true,
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestStdlib(t *testing.T) {
|
|||
SourceImports: true,
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func Build(ctxt *build.Context) (forward, reverse Graph, errors map[string]error
|
|||
}()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
buildutil.AllPackages(ctxt, func(path string, err error) {
|
||||
buildutil.ForEachPackage(ctxt, func(path string, err error) {
|
||||
if err != nil {
|
||||
errorc <- pathError{path, err}
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue