### The Go Memory Model
文章结尾有这么一段代码,理解的不是很透彻,谁给讲解一下,谢谢!
There are subtler variants on this theme, such as this program.
```
type T struct {
msg string
}
var g *T
func setup() {
t := new(T)
t.msg = "hello, world"
g = t
}
func main() {
go setup()
for g == nil {
}
print(g.msg)
}
```
Even if main observes g != nil and exits its loop, there is no guarantee that it will observe the initialized value for g.msg.
In all these examples, the solution is the same: use explicit synchronization.
实际上执行 go setup()时, go程并没有执行完,然后继续往下执行 for循环(只要g == nil一直循环下去),
直到go程返回结束,此时g != nil
#6