title: What is meant by race condition in GO when using -race flag
body: <p>Consider following code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "sync"
  )
  
  func main() {
  var a int
  m := new(sync.Mutex)
  
  wg := sync.WaitGroup{}
  wg.Add(2)
  
  go func(){
      m.Lock()
      a = 2
      m.Unlock()
      wg.Done()
  }()
  
  go func(){
      //m.Lock()
      a = 9
      //m.Unlock()
      wg.Done()
  }()
  
  wg.Wait()
  
  fmt.Println(a)
  }
  </code></pre>
  
  <p>if we run this code with -race flag we get warning that there is a race condition.</p>
  
  <p>1) what can possibly go wrong with this race condition?</p>
  
  <p>if we uncomment lock in second routine we don't get a race condition warning. But we can have different output so a race condition exists.</p>
  
  <p>2) Why now we don't have a race condition warning?</p>