Prototype: Prototype(events []Event) map[string]int processes signed deltas serially, includes every encountered key even if its final value is zero, returns a fresh nonnil map, preserves events. Empty key is valid.
Final: Counter must be usable as its zero value. Add(key string,delta int) int atomically adds signed delta, creates key even for zero, returns its new value. Get(key) int zero for missing, no creation. Snapshot() map[string]int coherent fresh nonnil map. Drain() map[string]int atomically returns detached map of all current entries then resets to empty. Every method is safe concurrently; operations must not lose increments and no shared returned map may expose internal mutable state. Do not copy Counter after use. Arithmetic fits int. All final tests should also pass under go run -race main.go exercise.go --stage final.
Edit exercise.go; retain the public types and signatures. prototype and final are separate stages. The executable tests recover panics from direct calls and harness-owned goroutines as named failures, including panic(nil). A panic in a goroutine started by your implementation must be recovered in that goroutine; its caller cannot recover it, and an unhandled panic can terminate the process. Cancellation is cooperative; the local CLI timeout remains the hard stop for unfinished waits. Tests exit nonzero on any failure. A successful run must execute at least one check. Tests use logical time or explicit synchronization where relevant.
Complete the starter code, then run the checks.
Results and errors will appear here.
Browser Go schedules goroutines cooperatively. These checks do not detect data races; use local Go with -race to check synchronization.