Concurrent code can overlap reads and writes even when a small test seems to run in a convenient order. A mutex protects an invariant by making one critical section exclusive. Lock and unlock the same mutex, keep the protected work short and use defer when an early return could otherwise leave it locked. A WaitGroup answers a different question: whether all jobs have finished. You often need both. These tasks update local counters and maps and initialize one value exactly once. The browser scheduler is single threaded, but the synchronization contract still matters when the same code runs on a normal Go target. This editor does not run the race detector. The checks verify outcomes and completion, while the worked source shows the intended coordination pattern.
Preserve every signed update.