Documentation
¶
Index ¶
- Constants
- type Hosts
- func (h *Hosts) Add(ip string, hosts ...string) error
- func (h *Hosts) Clean()
- func (h Hosts) Flush() error
- func (h Hosts) Has(ip string, host string) bool
- func (h Hosts) HasHostname(host string) bool
- func (h Hosts) HasIp(ip string) bool
- func (h *Hosts) HostsPerLine(count int)
- func (h *Hosts) IsWritable() bool
- func (h *Hosts) Load() error
- func (h *Hosts) Remove(ip string, hosts ...string) error
- func (h *Hosts) RemoveByHostname(host string) error
- func (h *Hosts) RemoveByIp(ip string) error
- func (h *Hosts) RemoveDuplicateIps()
- func (h *Hosts) SortByIp()
- type HostsLine
- func (l *HostsLine) Combine(hostline HostsLine)
- func (l *HostsLine) HasComment() bool
- func (l *HostsLine) IsComment() bool
- func (l *HostsLine) IsMalformed() bool
- func (l *HostsLine) IsValid() bool
- func (l *HostsLine) RegenRaw()
- func (l *HostsLine) RemoveDuplicateHosts()
- func (l *HostsLine) SortHosts()
- func (l *HostsLine) ToRaw() string
Constants ¶
View Source
const ( HostsPerLine = -1 // unlimited HostsFilePath = "/etc/hosts" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hosts ¶
func NewCustomHosts ¶
Return a new instance of “Hosts“ using a custom hosts file path.
func (Hosts) HasHostname ¶
Return a bool if hostname in hosts file.
func (*Hosts) HostsPerLine ¶ added in v0.0.6
func (*Hosts) IsWritable ¶
Return ```true``` if hosts file is writable.
func (*Hosts) Load ¶
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.
func (*Hosts) RemoveByHostname ¶
Remove entries by hostname from the hosts file.
func (*Hosts) RemoveByIp ¶
func (*Hosts) RemoveDuplicateIps ¶ added in v0.0.5
func (h *Hosts) RemoveDuplicateIps()
type HostsLine ¶
func NewHostsLine ¶
Return a new instance of ```HostsLine```.
func (*HostsLine) HasComment ¶ added in v0.0.3
func (*HostsLine) IsMalformed ¶
func (*HostsLine) RemoveDuplicateHosts ¶ added in v0.0.5
func (l *HostsLine) RemoveDuplicateHosts()
Click to show internal directories.
Click to hide internal directories.