dump out ip addresses of all nics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
371 B

package main
import (
"fmt"
"log"
"net"
)
func main() {
ifs, err := net.Interfaces()
if err != nil {
log.Fatal("problem geting interfaces")
}
for _, iff := range ifs {
as, err := iff.Addrs()
if err != nil {
log.Fatal("problem geting the address for interface.")
}
if len(as) != 0 {
fmt.Printf("%v: ", iff.Name)
fmt.Printf("%v\n", as)
}
}
}