Given the following 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)
}
}
}
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.