From d51e88b5aec5e5af4b3c8a4083777f5d1623d846 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Wed, 31 Oct 2018 14:51:16 -0400 Subject: [PATCH] go/packages: make visit order stable Change-Id: Iee9b29364dd986e1f1676ff0aa989267c4149c30 Reviewed-on: https://go-review.googlesource.com/c/146357 Run-TryBot: Ian Cottrell Run-TryBot: Michael Matloob TryBot-Result: Gobot Gobot Reviewed-by: Michael Matloob --- go/packages/visit.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go/packages/visit.go b/go/packages/visit.go index a50eb3b5..b13cb081 100644 --- a/go/packages/visit.go +++ b/go/packages/visit.go @@ -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]) }