title: Golang concurrency: how to append to the same slice from different goroutines
body: <p>I have concurrent goroutines which want to append a (pointer to a) struct to the same slice.
  How do you write that in Go to make it concurrency-safe?</p>
  
  <p>This would be my concurrency-unsafe code, using a wait group:</p>
  
  <pre><code>var wg sync.WaitGroup
  MySlice = make([]*MyStruct)
  for _, param := range params {
      wg.Add(1)
      go func(param string) {
          defer wg.Done()
          OneOfMyStructs := getMyStruct(param)
          MySlice = append(MySlice, &amp;OneOfMyStructs)
      }(param)
  }
  wg.Wait()
  </code></pre>
  
  <p>I guess you would need to use go channels for concurrency-safety. Can anyone contribute with an example?</p>