Skip to content

Commit c7408a8

Browse files
committed
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 <[email protected]>
1 parent e90f572 commit c7408a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/effective_go.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,13 +1680,13 @@ <h3 id="printing">Printing</h3>
16801680
fmt.Printf("%v\n", timeZone) // or just fmt.Println(timeZone)
16811681
</pre>
16821682
<p>
1683-
which gives output
1683+
which gives output:
16841684
</p>
16851685
<pre>
1686-
map[CST:-21600 PST:-28800 EST:-18000 UTC:0 MST:-25200]
1686+
map[CST:-21600 EST:-18000 MST:-25200 PST:-28800 UTC:0]
16871687
</pre>
16881688
<p>
1689-
For maps the keys may be output in any order, of course.
1689+
For maps, <code>Printf</code> and friends sort the output lexicographically by key.
16901690
When printing a struct, the modified format <code>%+v</code> annotates the
16911691
fields of the structure with their names, and for any value the alternate
16921692
format <code>%#v</code> prints the value in full Go syntax.
@@ -1710,7 +1710,7 @@ <h3 id="printing">Printing</h3>
17101710
&amp;{7 -2.35 abc def}
17111711
&amp;{a:7 b:-2.35 c:abc def}
17121712
&amp;main.T{a:7, b:-2.35, c:"abc\tdef"}
1713-
map[string]int{"CST":-21600, "PST":-28800, "EST":-18000, "UTC":0, "MST":-25200}
1713+
map[string]int{"CST":-21600, "EST":-18000, "MST":-25200, "PST":-28800, "UTC":0}
17141714
</pre>
17151715
<p>
17161716
(Note the ampersands.)

0 commit comments

Comments
 (0)