{"id":19349066,"url":"https://github.com/digineo/go-uci","last_synced_at":"2025-04-07T13:05:59.630Z","repository":{"id":49397989,"uuid":"172943042","full_name":"digineo/go-uci","owner":"digineo","description":"Native Go bindings for OpenWrt's UCI.","archived":false,"fork":false,"pushed_at":"2023-11-20T16:52:50.000Z","size":102,"stargazers_count":104,"open_issues_count":3,"forks_count":32,"subscribers_count":7,"default_branch":"v2","last_synced_at":"2025-03-31T11:04:11.440Z","etag":null,"topics":["configuration","configuration-management","go","lexer","native","openwrt","parser","uci"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digineo.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":"2019-02-27T15:42:44.000Z","updated_at":"2025-03-25T02:31:30.000Z","dependencies_parsed_at":"2024-06-18T17:12:14.442Z","dependency_job_id":null,"html_url":"https://github.com/digineo/go-uci","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digineo%2Fgo-uci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digineo%2Fgo-uci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digineo%2Fgo-uci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digineo%2Fgo-uci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digineo","download_url":"https://codeload.github.com/digineo/go-uci/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657276,"owners_count":20974344,"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":["configuration","configuration-management","go","lexer","native","openwrt","parser","uci"],"created_at":"2024-11-10T04:24:32.795Z","updated_at":"2025-04-07T13:05:59.611Z","avatar_url":"https://github.com/digineo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-uci\n\n\u003e **WORK IN PROGRESS**\n\u003e\n\u003e You're looking at the pre-release documentation for\n\u003e the next major **v2** version.\n\u003e\n\u003e Some things aren't properly flushed out yet and may\n\u003e break at any moment. Use at your own peril.\n\n\u003c!-- TODO: re-enable with v2 import path.\n[![GoDoc](https://pkg.go.dev/badge/github.com/digineo/go-uci.svg)](https://pkg.go.dev/github.com/digineo/go-uci)\n[![Test results](https://github.com/digineo/go-uci/workflows/Test/badge.svg)](https://github.com/digineo/go-uci/actions?query=workflow%3ATest)\n[![Lint results](https://github.com/digineo/go-uci/workflows/Lint/badge.svg)](https://github.com/digineo/go-uci/actions?query=workflow%3ALint)\n[![Codecov](http://codecov.io/github/digineo/go-uci/coverage.svg?branch=master)](http://codecov.io/github/digineo/go-uci?branch=master)\n--\u003e\n\nUCI is OpenWrt's [Unified Configuration Interface][uci-wiki]. It is\nused to configure OpenWrt router hardware using a simple DSL (and\nacompanying CLI tools). Configuration files are written into a\ncentral directory (`/etc/config/*`) which basically represents a\nkey/value store.\n\nThis project makes it easy to interact with such a config tree by\nproviding a native interface to that KV store. It has no external\nruntime dependencies.\n\nFor now, we only implements a superset of the actual UCI DSL, but\nimprovements (patches or PRs) are very welcome. Refer to Rob Pike's\n[Lexical Scanning in Go][pike-lex] for implementation details on the\nparser/lexer.\n\n[uci-wiki]: https://openwrt.org/docs/guide-user/base-system/uci\n[pike-lex]: https://talks.golang.org/2011/lex.slide\n\n## Why?\n\nWe're currently experimenting with Go binaries on OpenWrt router\nhardware and need a way to interact with the system configuration.\nWe could have created bindings for [`libuci`][uci-git], but the\nturnaround cycle in developing with CGO is a bit tedious. Also, since\nGo does not compile for our target platforms, we need to resort to\nGCCGO, which has other quirks.\n\nThe easiest solution therefore is a plain Go library, which can be\nused in Go (with or without CGO) and GCCGO without worrying about\ninteroperability. A library also allows UCI to be used outside of\nOpenWrt systems (e.g. for provisioning).\n\n[uci-git]: https://git.openwrt.org/?p=project/uci.git;a=summary\n\n\n## Usage\n\n\u003e TODO: update example\n\n```go\nimport \"github.com/digineo/go-uci\"\n\nfunc main() {\n    // use the default tree (/etc/config)\n    if values, ok := uci.Get(\"system\", \"@system[0]\", \"hostname\"); ok {\n        fmt.Println(\"hostanme\", values)\n        //=\u003e hostname [OpenWrt]\n    }\n\n    // use a custom tree\n    u := uci.NewTree(\"/path/to/config\")\n    if values, ok := u.Get(\"network\", \"lan\", \"ifname\"); ok {\n        fmt.Println(\"network.lan.ifname\", values)\n        //=\u003e network.lan.ifname [eth0.2]\n    }\n    if sectionExists := u.Set(\"network\", \"lan\", \"ipaddr\", \"192.168.7.1\"); !sectionExists {\n        _ = u.AddSection(\"network\", \"lan\", \"interface\")\n        _ = u.Set(\"network\", \"lan\", \"ipaddr\", \"192.168.7.1\")\n    }\n    u.Commit() // or uci.Revert()\n}\n```\n\nSee [API documentation][godoc] for more details.\n\n\n## Contributing\n\nPull requests are welcome, especially if they increase test coverage.\n\nBefore submitting changes, please make sure the tests still pass:\n\n```console\n$ go test github.com/digineo/go-uci/...\n```\n\n\n## License\n\nMIT License. Copyright (c) 2019 Dominik Menke, Digineo GmbH\n\n\u003chttps://www.digineo.de\u003e\n\nSee LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigineo%2Fgo-uci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigineo%2Fgo-uci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigineo%2Fgo-uci/lists"}