August 2019
Beginner to intermediate
798 pages
17h 2m
English
When the number of sync.Add() calls and sync.Done() calls are equal, everything will be fine in your programs. However, this section will tell you what will happen when these two numbers do not agree with each other.
If you have executed more sync.Add() calls than sync.Done() calls, in this case by adding a waitGroup.Add(1) statement before the first fmt.Printf("%#v\n", waitGroup) statement of the syncGo.go program, then the output of the go run command will be similar to the following:
$ go run syncGo.go
Going to create 20 goroutines.
sync.WaitGroup{noCopy:sync.noCopy{}, state1:[12]uint8{0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, sema:0x0}
sync.WaitGroup{noCopy:sync.noCopy{}, ...Read now
Unlock full access