{"id":18344102,"url":"https://github.com/b0ch3nski/go-hosts-file","last_synced_at":"2025-04-09T22:24:07.979Z","repository":{"id":220871663,"uuid":"752805461","full_name":"b0ch3nski/go-hosts-file","owner":"b0ch3nski","description":"Yet another Golang library for hosts file manipulation.","archived":false,"fork":false,"pushed_at":"2024-02-04T21:10:18.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T14:16:26.845Z","etag":null,"topics":["etc-hosts","golang","hosts","hosts-file","hostsfile"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b0ch3nski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-04T21:03:17.000Z","updated_at":"2024-02-04T22:08:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"f02529fb-cfd1-4093-b57b-4d94203987f7","html_url":"https://github.com/b0ch3nski/go-hosts-file","commit_stats":null,"previous_names":["b0ch3nski/go-hosts-file"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0ch3nski%2Fgo-hosts-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0ch3nski%2Fgo-hosts-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0ch3nski%2Fgo-hosts-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b0ch3nski%2Fgo-hosts-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b0ch3nski","download_url":"https://codeload.github.com/b0ch3nski/go-hosts-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248121061,"owners_count":21051070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["etc-hosts","golang","hosts","hosts-file","hostsfile"],"created_at":"2024-11-05T21:04:51.459Z","updated_at":"2025-04-09T22:24:07.955Z","avatar_url":"https://github.com/b0ch3nski.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-hosts-file\n[![license](https://img.shields.io/github/license/b0ch3nski/go-hosts-file)](LICENSE)\n[![release](https://img.shields.io/github/v/release/b0ch3nski/go-hosts-file)](https://github.com/b0ch3nski/go-hosts-file/releases)\n[![go.dev](https://pkg.go.dev/badge/github.com/b0ch3nski/go-hosts-file)](https://pkg.go.dev/github.com/b0ch3nski/go-hosts-file)\n[![goreportcard](https://goreportcard.com/badge/github.com/b0ch3nski/go-hosts-file)](https://goreportcard.com/report/github.com/b0ch3nski/go-hosts-file)\n[![issues](https://img.shields.io/github/issues/b0ch3nski/go-hosts-file)](https://github.com/b0ch3nski/go-hosts-file/issues)\n[![sourcegraph](https://sourcegraph.com/github.com/b0ch3nski/go-hosts-file/-/badge.svg)](https://sourcegraph.com/github.com/b0ch3nski/go-hosts-file)\n\nYet another Golang library for hosts file manipulation. Written for my own purposes but can be easily adopted for\nmultiple other use cases like merging hosts files, removing duplicates, validating, reverse lookups etc.\n\n## install\n\n```\ngo get github.com/b0ch3nski/go-hosts-file\n```\n\n## example\n\n```go\nhostsFile, _ := os.Open(\"/etc/hosts\")\n\nh := hosts.New()\nh.Read(hostsFile)\nh.Add(netip.AddrFrom4([4]byte{8, 8, 8, 8}), \"google.com\")\n\nfmt.Print(\u0026h)\nfmt.Println(h.GetIP(\"localhost\"))\nfmt.Println(h.GetAlias(netip.AddrFrom4([4]byte{127, 0, 0, 1})))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0ch3nski%2Fgo-hosts-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb0ch3nski%2Fgo-hosts-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb0ch3nski%2Fgo-hosts-file/lists"}