Skip to content

Commit

Permalink
fixing loc being the ln number
Browse files Browse the repository at this point in the history
  • Loading branch information
luthermonson committed Oct 29, 2023
1 parent ee819e1 commit 04a7d42
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func (h *Hosts) Add(ip string, hosts ...string) error {
} else {
// add new host to the first one we find
loc := position[len(position)-1] // last element
hostsCopy := make([]string, len(h.Lines[position[loc]].Hosts))
copy(hostsCopy, h.Lines[position[loc]].Hosts)
hostsCopy := make([]string, len(h.Lines[loc].Hosts))
copy(hostsCopy, h.Lines[loc].Hosts)

for _, addHost := range hosts {
if h.Has(ip, addHost) {
Expand All @@ -189,10 +189,10 @@ func (h *Hosts) Add(ip string, hosts ...string) error {
}

hostsCopy = append(hostsCopy, addHost)
h.hosts.add(addHost, position[loc])
h.hosts.add(addHost, loc)
}
h.Lines[position[loc]].Hosts = hostsCopy
h.Lines[position[loc]].RegenRaw()
h.Lines[loc].Hosts = hostsCopy
h.Lines[loc].RegenRaw()
}

return nil
Expand Down

0 comments on commit 04a7d42

Please sign in to comment.