From: Rob Pike Date: Wed, 6 Mar 2019 00:56:06 +0000 (+1100) Subject: doc: sort map output in Effective Go X-Git-Tag: go1.13beta1~1200 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c7408a87757f94ed72e3e2b7886880dcca946b28;p=gostls13.git doc: sort map output in Effective Go And explain that it does this. A minor change probably worth mentioning, although (#28782) I'd still like to freeze this document against any substantial changes. Fix #30568. Change-Id: I74c56744871cfaf00dc52a9b480ca61d3ed19a6b Reviewed-on: https://go-review.googlesource.com/c/go/+/165597 Reviewed-by: Brad Fitzpatrick --- diff --git a/doc/effective_go.html b/doc/effective_go.html index 34131868a4..b98235931c 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -1680,13 +1680,13 @@ maps. Here is a print statement for the time zone map defined in the previous s fmt.Printf("%v\n", timeZone) // or just fmt.Println(timeZone)

-which gives output +which gives output:

-map[CST:-21600 PST:-28800 EST:-18000 UTC:0 MST:-25200]
+map[CST:-21600 EST:-18000 MST:-25200 PST:-28800 UTC:0]
 

-For maps the keys may be output in any order, of course. +For maps, Printf and friends sort the output lexicographically by key. When printing a struct, the modified format %+v annotates the fields of the structure with their names, and for any value the alternate format %#v prints the value in full Go syntax. @@ -1710,7 +1710,7 @@ prints &{7 -2.35 abc def} &{a:7 b:-2.35 c:abc def} &main.T{a:7, b:-2.35, c:"abc\tdef"} -map[string]int{"CST":-21600, "PST":-28800, "EST":-18000, "UTC":0, "MST":-25200} +map[string]int{"CST":-21600, "EST":-18000, "MST":-25200, "PST":-28800, "UTC":0}

(Note the ampersands.)