1
0
mirror of https://github.com/golang/go synced 2024-11-23 05:10:09 -07:00

cmd/dist: make zosarch.go deterministic

Currently zosarch.go is written out in non-deterministic map order.
Sort the keys and write it out in sorted order to make the generated
file contents deterministic.

Change-Id: Id490f0e8665a2c619c5a7a00a30f4fc64f333258
Reviewed-on: https://go-review.googlesource.com/24174
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Austin Clements 2016-06-16 14:38:33 -04:00
parent c3818e56d0
commit 79f2f008a3

View File

@ -42,10 +42,21 @@ func mkzdefaultcc(dir, file string) {
// mkzcgo writes zosarch.go for cmd/go.
func mkzosarch(dir, file string) {
// sort for deterministic zosarch.go file
var list []string
for plat := range cgoEnabled {
list = append(list, plat)
}
sort.Strings(list)
var buf bytes.Buffer
buf.WriteString("// auto generated by go tool dist\n\n")
buf.WriteString("package main\n\n")
fmt.Fprintf(&buf, "var osArchSupportsCgo = %#v", cgoEnabled)
fmt.Fprintf(&buf, "var osArchSupportsCgo = map[string]bool{\n")
for _, plat := range list {
fmt.Fprintf(&buf, "\t%q: %v,\n", plat, cgoEnabled[plat])
}
fmt.Fprintf(&buf, "}\n")
writefile(buf.String(), file, writeSkipSame)
}