From 7fd4f8bb2fdac9b6ebb048fccf8d34da9bd83a10 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 27 Oct 2014 17:08:50 -0700 Subject: doc/go_mem.html: don't be clever Add a short introductory section saying what most Go programmers really need to know, which is that you shouldn't have to read this document to understand the behavior of your program. LGTM=bradfitz, adg, tracey.brendan, iant, rsc, dsymonds R=golang-codereviews, bradfitz, tracey.brendan, adg, iant, rsc, dsymonds CC=golang-codereviews https://codereview.appspot.com/158500043 --- doc/go_mem.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'doc') diff --git a/doc/go_mem.html b/doc/go_mem.html index 2ea1ded7a..5dd48ff7f 100644 --- a/doc/go_mem.html +++ b/doc/go_mem.html @@ -21,6 +21,29 @@ reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine.

+ +

Advice

+ +

+Programs that modify data being simultaneously accessed by multiple goroutines +must serialize such access. +

+ +

+To serialize access, protect the data with channel operations or other synchronization primitives +such as those in the sync +and sync/atomic packages. +

+ +

+If you must read the rest of this document to understand the behavior of your program, +you are being too clever. +

+ +

+Don't be clever. +

+

Happens Before

-- cgit v1.2.1