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>
diff --git a/go/packages/visit.go b/go/packages/visit.go
index a50eb3b..b13cb08 100644
--- a/go/packages/visit.go
+++ b/go/packages/visit.go
@@ -3,6 +3,7 @@
import (
"fmt"
"os"
+ "sort"
)
// Visit visits all the packages in the import graph whose roots are
@@ -23,6 +24,7 @@
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])
}