title: How do I get all IP addresses assigned to the machine?
body: <p>Given the following code:</p>
  
  <pre><code>// iptest
  package main
  
  import (
      "fmt"
      "net"
      "os"
  )
  
  func main() {
      host, _ := os.Hostname()
      addrs, _ := net.LookupIP(host)
      for _, addr := range addrs {
          if ipv4 := addr.To4(); ipv4 != nil {
              fmt.Println("IPv4: ", ipv4)
          }   
      }
  }
  </code></pre>
  
  <p>I'm having a problem where it only returns the first IP address assigned to the adapter.  This appears to be a problem only on systems that have a DNS suffix defined.  If one is not defined, it works fine and reports all IPs that have been assigned.</p>