From b6d91155835722e9a464b2676bb0664d792c1859 Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Sat, 25 Aug 2018 22:28:04 +0200 Subject: [PATCH] also ignore entries without ip during writing --- etchosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etchosts.go b/etchosts.go index 9028277..45a280f 100644 --- a/etchosts.go +++ b/etchosts.go @@ -88,7 +88,7 @@ func writeToEtcHosts(ipsToNames ipsToNamesMap, config ConfigSpec) error { } func writeEntryWithBanner(tmp io.Writer, ip string, names []string) error { - if len(names) > 0 { + if ip != "" && len(names) > 0 { log.Debugf("writing entry for %s (%s)", ip, names) if _, err := fmt.Fprintf(tmp, "%s\n%s\t%s\n", banner, ip, strings.Join(names, " ")); err != nil { return fmt.Errorf("error writing entry for %s: %s", ip, err)