title: Concurrent goroutines inside a for loop
body: <p>I have written goroutine inside for loop as follow. What I want is to execute the goroutine for each item in the listofDevices list concurrently but this logic is running goroutine for only one item in the listofDevices list.</p>
  
  <pre><code>    for _, ip := range listOfDevices {
              inChan &lt;- types.NewNotification(time.Now(), "/cloudtracer/status", nil,
                      &amp;map[key.Key]interface{}{
                              key.New(ip): types.Pointer{Pointer: "/cloudtracer/status/" + ip},
                      })
              pingOneMachine := probe.NewPing(ip, 2*time.Second, inChan)
              // For now stopping the probe after few minutes. This will change later
              ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
              defer cancel()
  
              wg.Add(len(listOfDevices))
              go func() {
                      defer wg.Done()
                      pingOneMachine.Run(ctx)
              }()
      }
      wg.Wait()
  </code></pre>
  
  <p>Can anyone help me in fixing this out?
  thanks in advance.</p>