From b194db21f8b02bb1eef465a381c5c1fd80642152 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 4 Feb 2015 01:52:37 -0800 Subject: [PATCH] Removed redundant Trim calls and added Parse impl. --- hostess.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hostess.go b/hostess.go index 7b70806..11eacaf 100644 --- a/hostess.go +++ b/hostess.go @@ -77,12 +77,12 @@ func parseLine(line string) []Hostname { words := strings.Split(line, " ") // Separate the first bit (the ip) from the other bits (the domains) - ip := TrimWS(words[0]) + ip := words[0] domains := words[1:] if LooksLikeIpv4(ip) || LooksLikeIpv6(ip) { for _, v := range domains { - v = TrimWS(v) + v = v hostnames = append(hostnames, Hostname{v, ip, enabled}) } } @@ -168,7 +168,9 @@ func (h *Hostfile) Load() string { func (h *Hostfile) Parse() { for _, v := range strings.Split(h.data, "\n") { - fmt.Println(v) + for _, hostname := range parseLine(v) { + h.Add(hostname) + } } }