Skip to content

Commit

Permalink
Merge pull request #23 from praveenkumar/add_clean
Browse files Browse the repository at this point in the history
Use clean to cleanup the host file
  • Loading branch information
gbraad authored Oct 18, 2021
2 parents 4eb2d25 + 3440409 commit 5126763
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/hosts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package hosts
import (
"fmt"
"regexp"
"runtime"
"sort"
"strings"

Expand Down Expand Up @@ -66,6 +67,11 @@ func (h *Hosts) Add(ip string, hosts []string) error {
if err := h.File.Add(ip, hostEntries...); err != nil {
return err
}
// Only execute clean in case of windows to avoid more than
// 9 domain entry in a single line
if runtime.GOOS == "windows" {
h.File.Clean()
}
return h.File.Flush()
}

Expand Down

0 comments on commit 5126763

Please sign in to comment.