Browse Source

add ability to remove entire section

tags/v3.2.0
Chris Wiegman 7 months ago
parent
commit
83f4fc4f3e
Signed by: chriswiegman <chris@chriswiegman.com> GPG Key ID: 2B23D7A74FDE2DF4
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      hostsFile.go

+ 13
- 0
hostsFile.go View File

@@ -2,6 +2,7 @@ package goodhosts

import (
"bufio"
"errors"
"fmt"
"net"
"os"
@@ -157,6 +158,18 @@ func (h *Hosts) Has(ip string, host string, forceFile bool) bool {
return pos != -1
}

// RemoveSection removes an entire section from the hostsfile
func (h *Hosts) RemoveSection() error {

if len(h.Section) == 0 {
return errors.New("No section Provided")
}

h.SectionLines = nil

return nil
}

// Remove an entry from the hosts file.
func (h *Hosts) Remove(ip string, hosts ...string) error {
var outputLines []HostsLine


Loading…
Cancel
Save