From 7ff68b365b68a7afa116b4dac0f1dcad989daa22 Mon Sep 17 00:00:00 2001
From: Russ Cox hello will print "hello, world"
at some point in the future (perhaps after hello has returned).
+The exit of a goroutine is not guaranteed to happen before +any event in the program. For example, in this program: +
+ +
+var a string
+
+func hello() {
+ go func() { a = "hello" }()
+ print(a)
+}
+
+
+
+the assignment to a is not followed by
+any synchronization event, so it is not guaranteed to be
+observed by any other goroutine.
+In fact, an aggressive compiler might delete the entire go statement.
+
+If the effects of a goroutine must be observed by another goroutine, +use a synchronization mechanism such as a lock or channel +communiation to establish a relative ordering. +
+-- 2.52.0