go-hosts-file

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: Apache-2.0

README

go-hosts-file

license release go.dev goreportcard issues sourcegraph

Yet another Golang library for hosts file manipulation. Written for my own purposes but can be easily adopted for multiple other use cases like merging hosts files, removing duplicates, validating, reverse lookups etc.

install

go get github.com/b0ch3nski/go-hosts-file

example

hostsFile, _ := os.Open("/etc/hosts")

h := hosts.New()
h.Read(hostsFile)
h.Add(netip.AddrFrom4([4]byte{8, 8, 8, 8}), "google.com")

fmt.Print(&h)
fmt.Println(h.GetIP("localhost"))
fmt.Println(h.GetAlias(netip.AddrFrom4([4]byte{127, 0, 0, 1})))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL