{"id":21910622,"url":"https://github.com/zieckey/goini","last_synced_at":"2025-04-06T22:08:58.907Z","repository":{"id":23263067,"uuid":"26621433","full_name":"zieckey/goini","owner":"zieckey","description":"A simple, flexible, efficient and powerful INI parser for Golang.","archived":false,"fork":false,"pushed_at":"2024-06-15T06:53:49.000Z","size":47,"stargazers_count":82,"open_issues_count":7,"forks_count":22,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T19:11:24.512Z","etag":null,"topics":["goini","ini","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zieckey.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":"2014-11-14T03:55:45.000Z","updated_at":"2025-03-23T18:09:50.000Z","dependencies_parsed_at":"2024-06-18T14:02:13.444Z","dependency_job_id":"00ce6fa9-60dd-40ce-8058-eb1b1edefcf3","html_url":"https://github.com/zieckey/goini","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zieckey%2Fgoini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zieckey%2Fgoini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zieckey%2Fgoini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zieckey%2Fgoini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zieckey","download_url":"https://codeload.github.com/zieckey/goini/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"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":["goini","ini","parser"],"created_at":"2024-11-28T17:32:31.349Z","updated_at":"2025-04-06T22:08:58.890Z","avatar_url":"https://github.com/zieckey.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## goini \n\n[![Build Status](https://secure.travis-ci.org/zieckey/goini.png)](http://travis-ci.org/zieckey/goini) [![Coverage Status](https://img.shields.io/coveralls/zieckey/goini.svg)](https://coveralls.io/r/zieckey/goini?branch=master)\n         \nThis is a Go package to interact with arbitrary INI.\n\nOur applications have a lot of memory data which are key/value pairs in the form of various separators NOT only `\\n`. \nI have not found any Golang open source code suitable for it. So I write it myself.\n\n`goini` is designed to be simple, flexible, efficient. It\n\n1. Supports the standard INI format\n1. Supports section\n1. Supports parsing INI file from local disk\n1. Supports parsing INI configuration data from memory\n1. Supports parsing data which are key/value pairs in the form of various separators NOT only `\\n`\n1. Supports UTF8 encoding\n1. Supports comments which has a leading character `;` or `#`\n1. Supports cascading inheritance\n1. Only depends standard Golang libraries\n1. Has 100% test coverage\n\n## Importing\n\n    import github.com/zieckey/goini\n\n## Usage\n\n### Example 1 : Parses an INI file\n\nThe simplest example code is :\n```go\nimport github.com/zieckey/goini\n\nini := goini.New()\nerr := ini.ParseFile(filename)\nif err != nil {\n\tfmt.Printf(\"parse INI file %v failed : %v\\n\", filename, err.Error())\n\treturn\n}\n\nv, ok := ini.Get(\"the-key\")\n//...\n```\n\n### Example 2 : Parses the memory data with similar format of INI\n\n```go\nraw := []byte(\"a:av||b:bv||c:cv||||d:dv||||||\")\nini := goini.New()\nerr := ini.Parse(raw, \"||\", \":\")\nif err != nil {\n    fmt.Printf(\"parse INI memory data failed : %v\\n\", err.Error())\n    return\n}\n\nkey := \"a\"\nv, ok := ini.Get(key)\nif ok {\n    fmt.Printf(\"The value of %v is [%v]\\n\", key, v) // Output : The value of a is [av]\n}\n\nkey = \"c\"\nv, ok = ini.Get(key)\nif ok {\n    fmt.Printf(\"The value of %v is [%v]\\n\", key, v) // Output : The value of c is [cv]\n}\n```\n\n### Example 3 : Parses an inherited INI file\n\nAssume we have a large project which has several production environments.\nEach production environment has its own configuration. \nBut there is tiny difference between these configurations of the standalone production environments.\nSo we use a common INI configuration to store the common configurations.\nAnd each production environment inherits from this common INI configuration.\n\nThe `common.ini` is bellow:\n \n```ini\nproduct=common\ncombo=common\ndebug=0\n\nversion=0.0.0.0\nencoding=0\n\n[sss]\na = aval\nb = bval\n```\n\nThe `project1.ini` is the configuration of project #1 as below:\n\n```ini\ninherited_from=common.ini\n\n;the following config will override the values inherited from common.ini\nproduct=project1\ncombo=test\ndebug=1\n\nlocal=0\nmid=c4ca4238a0b923820dcc509a6f75849b\n\n[sss]\na = project1-aval\nc = project1-cval\n```\n\nIf we use `goini.LoadInheritedINI(\"project1.ini\")` is the same as we have the following INI configuration:\n\n```ini\nproduct=project1\ncombo=test\ndebug=1\n\nlocal=0\nmid=c4ca4238a0b923820dcc509a6f75849b\n\nversion=0.0.0.0\nencoding=0\n\n[sss]\na = project1-aval\nc = project1-cval\n```\n\nThe value of the key `product` has been overwritten by value `project1`. \nThe value of the key `a` in section `sss` has been overwritten by value `project1-aval`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzieckey%2Fgoini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzieckey%2Fgoini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzieckey%2Fgoini/lists"}