mirror of
https://github.com/golang/go.git
synced 2025-11-03 10:10:55 +00:00
cmd/api: ignore internal packages
We might want to add a go/build.IsInternal(pkg string) bool later, but this works for now. LGTM=dave, rsc R=rsc, dave CC=golang-codereviews https://golang.org/cl/113300044
This commit is contained in:
parent
2ac289c4a0
commit
4676e260e3
2 changed files with 27 additions and 1 deletions
|
|
@ -107,6 +107,8 @@ func setContexts() {
|
|||
}
|
||||
}
|
||||
|
||||
var internalPkg = regexp.MustCompile(`(^|/)internal($|/)`)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
|
|
@ -132,7 +134,11 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pkgNames = strings.Fields(string(stds))
|
||||
for _, pkg := range strings.Fields(string(stds)) {
|
||||
if !internalPkg.MatchString(pkg) {
|
||||
pkgNames = append(pkgNames, pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var featureCtx = make(map[string]map[string]bool) // feature -> context name -> true
|
||||
|
|
|
|||
|
|
@ -142,6 +142,26 @@ func TestCompareAPI(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSkipInternal(t *testing.T) {
|
||||
tests := []struct {
|
||||
pkg string
|
||||
want bool
|
||||
}{
|
||||
{"net/http", true},
|
||||
{"net/http/internal-foo", true},
|
||||
{"net/http/internal", false},
|
||||
{"net/http/internal/bar", false},
|
||||
{"internal/foo", false},
|
||||
{"internal", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
got := !internalPkg.MatchString(tt.pkg)
|
||||
if got != tt.want {
|
||||
t.Errorf("%s is internal = %v; want %v", tt.pkg, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkAll(b *testing.B) {
|
||||
stds, err := exec.Command("go", "list", "std").Output()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue