Go Memory Model

  • Happens-before is the rule for visibility.
  • Without synchronization, writes are not guaranteed to be seen in order.

Safe publication

  • Build state first.
  • Publish once.
  • Do not mutate after publication.

Common patterns

  • sync.Mutex for mutable shared state.
  • channel close / receive for lifecycle boundaries.
  • atomic.Pointer[T] for immutable snapshots.

Anti-pattern

  • Reading shared variables with no edge.
  • Publishing mutable structs and updating later.

Practice focus

  • Implement a publish cell with atomic pointer swaps.
  • Distinguish empty, load, and swap semantics.
1 / 1
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.