{"id":23252734,"url":"https://github.com/ryosama/go-ini","last_synced_at":"2025-08-24T19:38:53.906Z","repository":{"id":80522324,"uuid":"145536616","full_name":"ryosama/go-ini","owner":"ryosama","description":"Simple Go librairy to deals with ini configuration files","archived":false,"fork":false,"pushed_at":"2018-09-24T07:36:02.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-15T17:09:09.906Z","etag":null,"topics":["go","golang","ini","inifile","lib","library"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryosama.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-08-21T09:00:53.000Z","updated_at":"2018-09-25T06:55:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"e86ca95f-a69e-4d8a-b978-93351b663292","html_url":"https://github.com/ryosama/go-ini","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ryosama/go-ini","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryosama%2Fgo-ini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryosama%2Fgo-ini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryosama%2Fgo-ini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryosama%2Fgo-ini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryosama","download_url":"https://codeload.github.com/ryosama/go-ini/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryosama%2Fgo-ini/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264363794,"owners_count":23596507,"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","golang","ini","inifile","lib","library"],"created_at":"2024-12-19T10:17:46.136Z","updated_at":"2025-07-08T23:06:55.733Z","avatar_url":"https://github.com/ryosama.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Go-ini\n======\n\nGo library to deals with ini configuration files\n\nInstall\n=======\n\n```bash\n$ go get -u github.com/ryosama/go-ini\n```\n\nQuick Start\n===========\n\n```Go\n// Load the library\nimport \"github.com/ryosama/go-ini\"\n\n// Create object\nmyIni := new(ini.Ini)\n\n// Load config file\nif err := myIni.LoadFromFile(\"config.ini\") ; err != nil {\n\tpanic(\"Unable to load configuration : \" + err.Error())\n}\n\n// Get the value\nmyHost, _ := myIni.Get(\"Server\",\"host\")\n\n// Set another value and save\nmyIni.Set(\"Server\",\"host\",\"127.0.0.1\")\nmyIni.Save()\n```\n\nDocumentation\n=======\n\nThe documentation can be found here : https://godoc.org/github.com/ryosama/go-ini\n\nOr export with this command\n\n```bash\n$ godoc github.com/ryosama/go-ini\n```\n\nCreating an object\n====\n    myIni := new(ini.Ini)\n\nObject properties\n=========\n    // Last filename pass to Load or Save\n    Filename string\n\n    // Add this string before section (default is \"\")\n    SectionPrefix string\n\n    // Add this string before every items (default is \"  \")\n    ItemPrefix string\n\n    // Add this string after every items (default is \" \")\n    ItemSuffix string\n\n    // Add this string before every values (default is \" \")\n    ValuePrefix string\n\n    // Add this string before every new sections (except the first one) (default is \"\\r\\n\")\n    SectionSeparator string\n\n    // Add this string before every new item (except the first one) (default is \"\\r\\n\")\n    ItemSeparator string\n\n    // If set to false, remove all the comments while saving (default is true)\n    WithComments bool\n\n    // Caractere(s) from prefixing a comment (default is \"; \")\n    CommentPrefix string\n    // contains filtered or unexported fields\nMethods\n======\n- AddItem\n\nAdd an item. Returns true if success, false if item already exists\n\n\tfunc (this *Ini) AddItem(section string, item string, value string) bool\n--------------------\n- AddItemComment\n\nAdd a comment to an item, return true if succeed, false otherwise\n\n\tfunc (this *Ini) AddItemComment(section string, item string, comment string) bool\n--------------------\n- AddSection\n\nAdd a section. Returns true if success, false if section already exists\n    \n\tfunc (this *Ini) AddSection(section string) bool\n--------------------\n- AddSectionComment\n\nAdd a comment to a setion, return true if succeed, false otherwise\n\n\tfunc (this *Ini) AddSectionComment(section string, comment string) bool\n--------------------\n- DeleteItem\n\nDelete an item, return true if succes, false if the item does not exists\n\n\tfunc (this *Ini) DeleteItem(section string, item string) bool\n--------------------\n- DeleteItemComment\n\nDelete the comment number id, return true if succeed, false otherwise\n\n\tfunc (this *Ini) DeleteItemComment(section string, item string, id int) bool\n--------------------  \n- DeleteItemComments\n\nDelete all the comments of an item, return true if succeed, false otherwise\n\n\tfunc (this *Ini) DeleteItemComments(section string, item string) bool\n--------------------\n- DeleteSection\n\nDelete a section, return true if succes, false if the section does not exists\n\n\tfunc (this *Ini) DeleteSection(section string) bool\n--------------------\n- DeleteSectionComment\n\nDelete the comment number id, return true if succeed, false otherwise\n\n\tfunc (this *Ini) DeleteSectionComment(section string, id int) bool\n--------------------\n- DeleteSectionComments\n\nDelete all the comments of a section, return true if succeed, false\n    otherwise\n\n\tfunc (this *Ini) DeleteSectionComments(section string) bool\n    \n--------------------\n- Exists\n\nAlias for ItemExists\n\n\tfunc (this *Ini) Exists(section string, item string) bool\n--------------------\n- Get\n\nAlias for GetItem\n\n\tfunc (this *Ini) Get(section string, item string) (string, bool)\n--------------------\n- GetItem\n\nReturns the items value of the ini file for a given section and item\n    (and true as second return value)\n\nIf the item does not exists, return false as second return value\n\n\tfunc (this *Ini) GetItem(section string, item string) (string, bool)\n\nExample :\n\n    value, success := myini.GetItem(\"section1\",\"item1\")\n--------------------\n- GetItemComments\n\nReturn the comments, one per line, just before the item, return empty slice of string if item does not exists.\n\n\tfunc (this *Ini) GetItemComments(section string, item string) []string\n\nExample :\n\n    for _, com := range myIni.GetItemComments(\"mySection\",\"myItem\") {\n\t\tprint(\"Comment for myItem\", com, \"\\n\")\n    }\n--------------------\n- GetItems\n\nReturns all the items of the ini file for a given section\n\n\tfunc (this *Ini) GetItems(section string) []string\n--------------------\n- GetSectionComments\n\n\nReturn the comments, one per line, just before the section, return empty slice of string if section does not exists.\n\n\tfunc (this *Ini) GetSectionComments(section string) []string\n    \nExample :\n\n    for _, com := range sectionExists := myIni.GetSectionComments(\"mySection\") {\n\t\tprint(\"Comment for mySection\", com, \"\\n\")\n    }\n--------------------\n- GetSections\n\nReturns all the sections of the ini file\n\n\tfunc (this *Ini) GetSections() []string\n--------------------\n- ItemExists\n\nReturns true or false if the item exists for the given section\n\n\tfunc (this *Ini) ItemExists(section string, item string) bool\n--------------------\n- LoadFromFile\n\nRead ini format from a file\n\n\tfunc (this *Ini) LoadFromFile(filename string) error\n    \nExample :\n\n    err := myIni.LoadFromFile(\"config.ini\")\n--------------------\n- LoadFromString\n\nLoad data from a string pointer\n\n\tfunc (this *Ini) LoadFromString(content *string)\n\nExample :   \n\n    content := `\n\n    [section1]\n\n    item1=value1`\n\n    myini.LoadFromString( \u0026content )\n--------------------\n- Print\n\nPrint the ini format into a formatted string\n\nTIPS : You can set _SectionPrefix,ItemPrefix, ItemSuffix, ValuePrefix, SectionSeparator, ItemSeparator, WithComments, CommentPrefix_ to tweak format aspect\n\n\tfunc (this *Ini) Print()\n--------------------\n- RenameItem\n\nRename an item. Returns true if success, false if section or item does not exists\n\n\tfunc (this *Ini) RenameItem(section, oldName string, newName string) bool\n--------------------\n- RenameSection\n\nRename a section. Returns true if success, false if section does not exists\n\n\tfunc (this *Ini) RenameSection(oldName string, newName string) bool\n--------------------\n- Save\n\nSave the ini format to a file\n\n\tfunc (this *Ini) Save(params ...string) error\n    \nExample :\n\n\terr := myIni.Save() // use myIni.Filename to save\n    err := myIni.Save(\"new_config.ini\") // use new_config.ini and set\n    myIni.Filename\n--------------------\n- SectionExists\n\nReturns true or false if the section exists\n\n\tfunc (this *Ini) SectionExists(section string) bool\n--------------------\n- Set\n\nAlias for SetItem\t\n\n\tfunc (this *Ini) Set(section string, item string, value string) bool\n--------------------\n- SetItem\n\nSet the value of an item. Returns true if success, false section or item does not exists\n\n\tfunc (this *Ini) SetItem(section string, item string, value string) bool\n--------------------\n- SetOrCreate\n\nSet a value for an item, create section and item if needed\n\n\tfunc (this *Ini) SetOrCreate(section string, item string, value string)\n--------------------\n- Sprint\n\nReturn the ini format into a formatted string\n\nTIPS : You can set _SectionPrefix,ItemPrefix, ItemSuffix, ValuePrefix, SectionSeparator, ItemSeparator, WithComments, CommentPrefix_ to tweak format aspect\n\n\tfunc (this *Ini) Sprint() string","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryosama%2Fgo-ini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryosama%2Fgo-ini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryosama%2Fgo-ini/lists"}