title: Are creating go routines asynchrnous?
body: <p>I'm trying to fetch the content of an API with numerous goroutines.
  I'm using a for loop to iterate over different character, but it seems like the forloop reaches its final value, before the requests are sent off.</p>
  <pre><code>package main
  
  import (
      &quot;encoding/json&quot;
      &quot;fmt&quot;
      &quot;net/http&quot;
      &quot;sync&quot;
  )
  
  type people struct {
      Name string `json:&quot;name&quot;`
  }
  
  func main(){
  
      names := make(chan string, 25)
      var wg sync.WaitGroup
      for i := 0; i &lt; 25; i++ {
          wg.Add(1)
          go func() {
              defer wg.Done()
              var p people
              url := fmt.Sprintf(&quot;https://swapi.dev/api/people/%d&quot;, i)
              getJSON(url, &amp;p)
              names &lt;- p.Name
          }()
      }
      name := &lt;-names
      fmt.Println(name)
      wg.Wait()
  
  }
  
  func getJSON(url string, target interface{}) error {
      r, err := http.Get(url)
      if err != nil {
          return err
      }
      defer r.Body.Close()
      json.NewDecoder(r.Body).Decode(target)
      return nil
  }
  </code></pre>
  <p>Also, if somebody could improve my code quality, I'd be very grateful, I'm very new to Golang and don't have anybody to learn from!</p>