title: How to call a function in parallel in Go
body: <p>I am trying to run a function in parallel.... when I do it </p>
  
  <pre><code>func runParallel() {
      var out [5]chan string
      for i := range out {
          out[i] = make(chan string)
      }
      for j:=0; j&lt;2; j++ {
          fmt.Println("\nStarting: ", j)
          go func() {
              out[0] &lt;- f3(4)
          }()
  
          fmt.Println(&lt;-out[0])
      }
  }
  
  func main() {    
      runParallel()
  }
  </code></pre>
  
  <p>I see that function gets called serially one after the other... but when i do..</p>
  
  <pre><code>func runParallel() {
      var out [5]chan string
      for i := range out {
          out[i] = make(chan string)
      }
  
      fmt.Println("\nStarting: ", j)
      go func() {
          out[0] &lt;- f3(4)
      }()
      go func() {
          out[0] &lt;- f3(4)
      }()
  
      fmt.Println(&lt;-out[0])
  }
  
  func main() {    
      runParallel()
  }
  </code></pre>
  
  <p>The function gets called parallel.  </p>
  
  <p>I need to get the function called parallel in a for loop, Please help.</p>