1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:14:40 -07:00

go/packages: make visit order stable

Change-Id: Iee9b29364dd986e1f1676ff0aa989267c4149c30
Reviewed-on: https://go-review.googlesource.com/c/146357
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Ian Cottrell 2018-10-31 14:51:16 -04:00
parent 45ff765b48
commit d51e88b5ae

View File

@ -3,6 +3,7 @@ package packages
import (
"fmt"
"os"
"sort"
)
// Visit visits all the packages in the import graph whose roots are
@ -23,6 +24,7 @@ func Visit(pkgs []*Package, pre func(*Package) bool, post func(*Package)) {
for path := range pkg.Imports {
paths = append(paths, path)
}
sort.Strings(paths) // Imports is a map, this makes visit stable
for _, path := range paths {
visit(pkg.Imports[path])
}