diff options
author | Kevin Wallace <kevin@pentabarf.net> | 2016-06-10 03:05:49 -0700 |
---|---|---|
committer | Kevin Wallace <kevin@pentabarf.net> | 2016-06-10 03:05:49 -0700 |
commit | 631f39335c078dc6f1caa50b42bcae9479f32b25 (patch) | |
tree | 3d712dd65e93214fa112279698d2ded0c478e8d1 | |
parent | give up trying to distinguish 1.2.3.4 from ::ffff:1.2.3.4 (diff) |
use stderr responsibly
-rw-r--r-- | main.go | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -18,13 +18,11 @@ func main() { for _, ipnet := range ipnets { ip := ipnet.IP for ipnet.Contains(ip) { - line := ip.String() + "\t" - names, err := net.LookupAddr(ip.String()) - line += strings.Join(names, " ") - if err != nil { - line += fmt.Sprintf(" # %s", err) + if names, err := net.LookupAddr(ip.String()); err != nil { + fmt.Fprintf(os.Stderr, "%s\t# error: %s\n", ip, err) + } else { + fmt.Printf("%s\t%s\n", ip, strings.Join(names, " ")) } - fmt.Println(line) ip = next(ip) } } |