title: How to get all addresses and masks from local interfaces in go?
body: <p>How can I get all addresses and masks from local interfaces in golang?</p>
  
  <p>I need the actual network mask configured along with every IP address.</p>
  
  <p>This code does not show the network masks in Windows 7:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "log"
      "net"
  )
  
  func localAddresses() {
      ifaces, err := net.Interfaces()
      if err != nil {
          log.Print(fmt.Errorf("localAddresses: %v\n", err.Error()))
          return
      }
      for _, i := range ifaces {
          addrs, err := i.Addrs()
          if err != nil {
              log.Print(fmt.Errorf("localAddresses: %v\n", err.Error()))
              continue
          }
          for _, a := range addrs {
              log.Printf("%v %v\n", i.Name, a)
          }
      }
  }
  
  func main() {
      localAddresses()
  }
  </code></pre>
  
  <p>UPDATE: This issue has been fixed in Go: <a href="https://github.com/golang/go/issues/5395" rel="noreferrer">https://github.com/golang/go/issues/5395</a></p>