/*ChangeResult result of changing the hosts file.*/
typeChangeResultstruct{
Successbool
Alteredbool
Contentstring
WriteFilestring
}
/*AddHosts attempts to add requested hosts to the system hosts file, and gives you the new content, a tmp file and success.*/
funcAddHosts(toAdd[]string)Save{
funcAddHosts(toAdd[]string)ChangeResult{
hosts:=hosts()
serviceIP:="127.0.0.1"
...
...
@@ -55,14 +56,14 @@ func AddHosts(toAdd []string) Save {
// TODO when the library supports it do ipv6 too https://github.com/txn2/txeh/issues/15
// hosts.AddHosts("::1", toAdd)
returnsave(hosts)
returnfinishChanges(hosts)
}
/*RemoveHostsWithSuffix attempts to remove all hosts with a suffix from the system hosts file, and gives you the new content, a tmp file and success.*/