{"id":17717282,"url":"https://github.com/bwesterb/go-zonefile","last_synced_at":"2025-04-15T03:53:51.767Z","repository":{"id":46032362,"uuid":"74137543","full_name":"bwesterb/go-zonefile","owner":"bwesterb","description":"Go package to edit DNS/Bind zone files (preserving formatting \u0026 comments)","archived":false,"fork":false,"pushed_at":"2024-07-29T08:40:56.000Z","size":23,"stargazers_count":31,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T03:53:45.321Z","etag":null,"topics":["go","parser","zone-files"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/bwesterb/go-zonefile","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bwesterb.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":"2016-11-18T14:38:35.000Z","updated_at":"2025-02-16T13:16:41.000Z","dependencies_parsed_at":"2024-10-25T22:54:54.951Z","dependency_job_id":null,"html_url":"https://github.com/bwesterb/go-zonefile","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fgo-zonefile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fgo-zonefile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fgo-zonefile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fgo-zonefile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwesterb","download_url":"https://codeload.github.com/bwesterb/go-zonefile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003955,"owners_count":21196794,"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":["go","parser","zone-files"],"created_at":"2024-10-25T14:19:41.059Z","updated_at":"2025-04-15T03:53:51.751Z","avatar_url":"https://github.com/bwesterb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-zonefile\nGo package to edit DNS/Bind zone files (preserving formatting \u0026 comments)\n\n`go-zonefile` is not finished: interfaces, documentation and convenience functions are missing.\nAll the lexing and parsing is finished, though.\n\n**[Online documentation and examples](https://godoc.org/github.com/bwesterb/go-zonefile)**\n\nBundled as an example (and actually the original reason why I wrote this package)\nis the `inc-zonefile-serial` utility, which increments the serial in a zonefile:\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"github.com/bwesterb/go-zonefile\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"strconv\"\n)\n\n// Increments the serial of a zonefile\nfunc main() {\n\tif len(os.Args) != 2 {\n\t\tfmt.Println(\"Usage:\", os.Args[0], \"\u003cpath to zonefile\u003e\")\n\t\tos.Exit(1)\n\t}\n\n\t// Load zonefile\n\tdata, ioerr := ioutil.ReadFile(os.Args[1])\n\tif ioerr != nil {\n\t\tfmt.Println(os.Args[1], ioerr)\n\t\tos.Exit(2)\n\t}\n\n\tzf, perr := zonefile.Load(data)\n\tif perr != nil {\n\t\tfmt.Println(os.Args[1], perr.LineNo(), perr)\n\t\tos.Exit(3)\n\t}\n\n\t// Find SOA entry\n\tok := false\n\tfor _, e := range zf.Entries() {\n\t\tif !bytes.Equal(e.Type(), []byte(\"SOA\")) {\n\t\t\tcontinue\n\t\t}\n\t\tvs := e.Values()\n\t\tif len(vs) != 7 {\n\t\t\tfmt.Println(\"Wrong number of parameters to SOA line\")\n\t\t\tos.Exit(4)\n\t\t}\n\t\tserial, err := strconv.Atoi(string(vs[2]))\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Could not parse serial:\", err)\n\t\t\tos.Exit(5)\n\t\t}\n\t\te.SetValue(2, []byte(strconv.Itoa(serial+1)))\n\t\tok = true\n\t\tbreak\n\t}\n\tif !ok {\n\t\tfmt.Println(\"Could not find SOA entry\")\n\t\tos.Exit(6)\n\t}\n\n\tfh, err := os.OpenFile(os.Args[1], os.O_WRONLY, 0)\n\tif err != nil {\n\t\tfmt.Println(os.Args[1], err)\n\t\tos.Exit(7)\n\t}\n\n\t_, err = fh.Write(zf.Save())\n\tif err != nil {\n\t\tfmt.Println(os.Args[1], err)\n\t\tos.Exit(8)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwesterb%2Fgo-zonefile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwesterb%2Fgo-zonefile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwesterb%2Fgo-zonefile/lists"}