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

Two goroutines run the functions below with no other synchronization. Under the Go memory model, which outcome is explicitly permitted (even on a strongly-ordered x86), demonstrating that the model allows it?

var x, y int var r1, r2 int // goroutine 1 func g1() { x = 1 r1 = y } // goroutine 2 func g2() { y = 1 r2 = x }