package main

import (
	"fmt"
	"sync"
)

// section: code
func main() {
	wg := &sync.WaitGroup{}
	wg.Add(1)
	go count(5, wg)
	wg.Wait()
}

func count(i int, wg *sync.WaitGroup) {
	defer wg.Done()
	for j := 0; j < i; j++ {
		fmt.Println("processing...", j)
	}
}

// section: code

/*
// section: output
$ go run ./main.go
processing... 0
processing... 1
processing... 2
processing... 3
processing... 4
// section: output
*/
