ermos/hostsfile

View on GitHub
hosts.go

Summary

Maintainability
A
0 mins
Test Coverage
package hostsfile

// Hosts represents a hosts file.
type Hosts struct {
    path string
    rows []hostRow
}

type hostRow struct {
    raw  string
    host *Host
}

func (hosts *Hosts) GetPath() string {
    return hosts.path
}

func (hosts *Hosts) GetHosts() []*Host {
    var list []*Host

    for _, l := range hosts.rows {
        if l.host != nil {
            list = append(list, l.host)
        }
    }

    return list
}