// 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 packagesimport ()// 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)varfunc(*Package) = func( *Package) {if ![] { [] = trueif == nil || () { := make([]string, 0, len(.Imports))for := range .Imports { = append(, ) }sort.Strings() // Imports is a map, this makes visit stablefor , := 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 {varint := make(map[*Module]bool)Visit(, nil, func( *Package) {for , := range .Errors {fmt.Fprintln(os.Stderr, ) ++ }// Print pkg.Module.Error once if present. := .Moduleif != nil && .Error != nil && ![] { [] = truefmt.Fprintln(os.Stderr, .Error.Err) ++ } })return}
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)