title: How do I get the local IP address in Go?
body: <p>I want to get the computer's IP address. I used the code below, but it returns <code>127.0.0.1</code>.</p>
  
  <p>I want to get the IP address, such as <code>10.32.10.111</code>, instead of the loopback address. </p>
  
  <pre><code>name, err := os.Hostname()
  if err != nil {
       fmt.Printf("Oops: %v\n", err)
       return
  }
  
  addrs, err := net.LookupHost(name)
  if err != nil {
      fmt.Printf("Oops: %v\n", err)
      return
  }
  
  for _, a := range addrs {
      fmt.Println(a)
  }  
  </code></pre>