Skip to content

Commit

Permalink
Merge pull request #53 from goodhosts/fix-loc
Browse files Browse the repository at this point in the history
fixing loc being the ln number
  • Loading branch information
luthermonson authored Oct 29, 2023
2 parents ee819e1 + 04a7d42 commit d043bb3
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 d043bb3

Please sign in to comment.