aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/sync/example_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/sync/example_test.go')
-rw-r--r--libgo/go/sync/example_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/libgo/go/sync/example_test.go b/libgo/go/sync/example_test.go
index 1564924..031c87f 100644
--- a/libgo/go/sync/example_test.go
+++ b/libgo/go/sync/example_test.go
@@ -24,10 +24,10 @@ func ExampleWaitGroup() {
wg.Add(1)
// Launch a goroutine to fetch the URL.
go func(url string) {
+ // Decrement the counter when the goroutine completes.
+ defer wg.Done()
// Fetch the URL.
http.Get(url)
- // Decrement the counter.
- wg.Done()
}(url)
}
// Wait for all HTTP fetches to complete.
@@ -37,7 +37,7 @@ func ExampleWaitGroup() {
func ExampleOnce() {
var once sync.Once
onceBody := func() {
- fmt.Printf("Only once\n")
+ fmt.Println("Only once")
}
done := make(chan bool)
for i := 0; i < 10; i++ {