I have a simple struct that contains a map: type S struct { m map[string]bool}.
The struct has a method for reading it: func (s *S) Foo(key string) bool { return s.m[key] }.
It also has a method to update it: func (s *S) Update() { newm := map[string]bool{}; /* computation */ s.m = newm }
My question is: is it safe to use call these functions from independent coroutines without using mutexes to guard the access to m? If I read the Go memory model correctly I think that the answer is yes, because this code is not reading and writing to the same map concurrently: it's accessing a variable that could be updated, and the access to a single variable is atomic, and the compiler will not reorder s.m = newm so that it gets executed before the map is updated. Am I right?