Source File
visit.go
Belonging Package
golang.org/x/tools/go/packages
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package packages
import (
)
// Visit visits all the packages in the import graph whose roots are
// pkgs, calling the optional pre function the first time each package
// is encountered (preorder), and the optional post function after a
// package's dependencies have been visited (postorder).
// The boolean result of pre(pkg) determines whether
// the imports of package pkg are visited.
func ( []*Package, func(*Package) bool, func(*Package)) {
:= make(map[*Package]bool)
var func(*Package)
= func( *Package) {
if ![] {
[] = true
if == nil || () {
:= make([]string, 0, len(.Imports))
for := range .Imports {
= append(, )
}
sort.Strings() // Imports is a map, this makes visit stable
for , := range {
(.Imports[])
}
}
if != nil {
()
}
}
}
for , := range {
()
}
}
// PrintErrors prints to os.Stderr the accumulated errors of all
// packages in the import graph rooted at pkgs, dependencies first.
// PrintErrors returns the number of errors printed.
func ( []*Package) int {
var int
Visit(, nil, func( *Package) {
for , := range .Errors {
fmt.Fprintln(os.Stderr, )
++
}
})
return
}
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)