aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wallace <kevin@pentabarf.net>2016-06-10 03:05:49 -0700
committerKevin Wallace <kevin@pentabarf.net>2016-06-10 03:05:49 -0700
commit631f39335c078dc6f1caa50b42bcae9479f32b25 (patch)
tree3d712dd65e93214fa112279698d2ded0c478e8d1
parentgive up trying to distinguish 1.2.3.4 from ::ffff:1.2.3.4 (diff)
use stderr responsibly
-rw-r--r--main.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/main.go b/main.go
index 51fa6cb..2096965 100644
--- a/main.go
+++ b/main.go
@@ -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)
}
}