title: Example for sync.WaitGroup correct?
body: <p>Is this example usage of <code>sync.WaitGroup</code> correct? It gives the expected result, but I am unsure about the <code>wg.Add(4)</code> and the position of <code>wg.Done()</code>. Does it make sense to add the four goroutines at once with <code>wg.Add()</code>?</p>
  
  <p><a href="http://play.golang.org/p/ecvYHiie0P">http://play.golang.org/p/ecvYHiie0P</a></p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "sync"
      "time"
  )
  
  func dosomething(millisecs time.Duration, wg *sync.WaitGroup) {
      duration := millisecs * time.Millisecond
      time.Sleep(duration)
      fmt.Println("Function in background, duration:", duration)
      wg.Done()
  }
  
  func main() {
      var wg sync.WaitGroup
      wg.Add(4)
      go dosomething(200, &amp;wg)
      go dosomething(400, &amp;wg)
      go dosomething(150, &amp;wg)
      go dosomething(600, &amp;wg)
  
      wg.Wait()
      fmt.Println("Done")
  }
  </code></pre>
  
  <p>Result (as expected):</p>
  
  <pre><code>Function in background, duration: 150ms
  Function in background, duration: 200ms
  Function in background, duration: 400ms
  Function in background, duration: 600ms
  Done
  </code></pre>