From fcbcd37d6473d287176aecd8a341f1c69d0f19b6 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 31 May 2018 06:51:08 +1000 Subject: blog/content/go-maps-in-action: clean up ambiguous final paragraph Rewrite final paragraph for clarity. The grammar was ambiguous and confusing. Break up the huge paragraph into multiple lines. I left the rest of the document untouched to localize the changes. Fixes golang/go#25647. Change-Id: I8f3b54c3429e60658437731c357e7e7feb8937f3 Reviewed-on: https://go-review.googlesource.com/115395 Reviewed-by: Brad Fitzpatrick --- content/go-maps-in-action.article | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'content/go-maps-in-action.article') diff --git a/content/go-maps-in-action.article b/content/go-maps-in-action.article index e57edc6..7cca838 100644 --- a/content/go-maps-in-action.article +++ b/content/go-maps-in-action.article @@ -170,7 +170,11 @@ To write to the counter, take the write lock: * Iteration order -When iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to be the same from one iteration to the next. Since Go 1 the runtime randomizes map iteration order, as programmers relied on the stable iteration order of the previous implementation. If you require a stable iteration order you must maintain a separate data structure that specifies that order. This example uses a separate sorted slice of keys to print a `map[int]string` in key order: +When iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to be the same from one iteration to the next. +Since the release of Go 1.0, the runtime has randomized map iteration order. +Programmers had begun to rely on the stable iteration order of early versions of Go, which varied between implementations, leading to portability bugs. +If you require a stable iteration order you must maintain a separate data structure that specifies that order. +This example uses a separate sorted slice of keys to print a `map[int]string` in key order: import "sort" -- cgit v1.2.3