diff --git a/ch1-basic/ch1-05-mem.md b/ch1-basic/ch1-05-mem.md index ed7712c..4ccb955 100644 --- a/ch1-basic/ch1-05-mem.md +++ b/ch1-basic/ch1-05-mem.md @@ -61,17 +61,21 @@ import ( "sync/atomic" ) -var total int64 +var total uint64 func worker(wg *sync.WaitGroup) { defer wg.Done() - for i := 0; i <= 100; i++ { + var i uint64 + for i = 0; i <= 100; i++ { atomic.AddUint64(&total, i) } } func main() { + var wg sync.WaitGroup + wg.Add(2) + go worker(&wg) go worker(&wg) wg.Wait()