diff options
author | Michael Matloob <matloob@golang.org> | 2020-01-30 17:12:53 -0500 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2020-01-30 22:45:04 +0000 |
commit | fe90550fed74c4990e5e7416f52b1f25d61d0c73 (patch) | |
tree | e7140f9071fcd37030e0436251f0f923f451c881 /go/packages/golist.go | |
parent | 0725381040373f87e53f74b3416069109eceb74e (diff) | |
download | golang-x-tools-fe90550fed74c4990e5e7416f52b1f25d61d0c73.tar.gz |
go/packages: fix non-determinism on package list order
Even though users shouldn't depend on the order of the package list,
go/packages.Load should still return packages in a deterministic order.
golang.org/cl/216721 broke the determinism by getting package
order using a map. Fix that by sorting the packages.
Updates golang/go#36908
Change-Id: Icf8476009abfc27009d494eb57712caeb0775343
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217087
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'go/packages/golist.go')
-rw-r--r-- | go/packages/golist.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/go/packages/golist.go b/go/packages/golist.go index 639639fed..fc0b28ecf 100644 --- a/go/packages/golist.go +++ b/go/packages/golist.go @@ -16,6 +16,7 @@ import ( "path" "path/filepath" "reflect" + "sort" "strconv" "strings" "sync" @@ -627,6 +628,7 @@ func (state *golistState) createDriverResponse(words ...string) (*driverResponse for _, pkg := range pkgs { response.Packages = append(response.Packages, pkg) } + sort.Slice(response.Packages, func(i, j int) bool { return response.Packages[i].ID < response.Packages[j].ID }) return &response, nil } |