Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGoGo memory model and happens-beforeSingle-choice MCQ

Two goroutines run after the main goroutine starts them. Under the Go memory model, what does the program guarantee about the read of `done` and the value of `msg`?

var msg string var done bool func setup() { msg = "hello" done = true } func main() { go setup() for !done { } print(msg) }