goodhosts.go
func (h *Hosts) Load() error {
	var lines []HostsLine

	file, err := os.Open(h.Path)
	if err != nil {
		return err
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		line := NewHostsLine(scanner.Text())
		if err != nil {
			return err
		}

		lines = append(lines, line)
	}

	if err := scanner.Err(); err != nil {
		return err
	}

	h.Lines = lines

	return nil
}
func (h *Hosts) Load() error {
	var lines []HostsLine

	file, err := os.Open(h.Path)
	if err != nil {
		return err
	}
	defer file.Close()

	scanner := bufio.NewScanner(file)
	for scanner.Scan() {
		line := NewHostsLine(scanner.Text())
		if err != nil {
			return err
		}

		lines = append(lines, line)
	}

	if err := scanner.Err(); err != nil {
		return err
	}

	h.Lines = lines

	return nil
}
func ( h * Hosts ) Load ( ) error { var lines [ ] HostsLine file , err := os . Open ( h . Path ) if err != nil { return err } defer file . Close ( ) scanner := bufio . NewScanner ( file ) for scanner . Scan ( ) { line := NewHostsLine ( scanner . Text ( ) ) if err != nil { return err } lines = append ( lines , line ) } if err := scanner . Err ( ) ; err != nil { return err } h . Lines = lines return nil }
// Load the hosts file into ```l.Lines```.
// ```Load()``` is called by ```NewHosts()``` and ```Hosts.Flush()``` so you
// generally you won't need to call this yourself.
Load the hosts file into l . Lines . Load () is called by NewHosts () and Hosts . Flush () so you generally you won t need to call this yourself .