{"id":20144724,"url":"https://github.com/widuu/goini","last_synced_at":"2025-08-21T12:30:35.487Z","repository":{"id":15479068,"uuid":"18212618","full_name":"widuu/goini","owner":"widuu","description":"golang读取ini配置文件","archived":false,"fork":false,"pushed_at":"2022-11-16T00:39:38.000Z","size":12,"stargazers_count":83,"open_issues_count":5,"forks_count":42,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-12-07T10:10:24.780Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.widuu.com/archives/02/961.html","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/widuu.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}},"created_at":"2014-03-28T13:18:12.000Z","updated_at":"2023-07-25T13:51:21.000Z","dependencies_parsed_at":"2023-01-13T18:26:53.025Z","dependency_job_id":null,"html_url":"https://github.com/widuu/goini","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fgoini","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fgoini/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fgoini/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widuu%2Fgoini/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/widuu","download_url":"https://codeload.github.com/widuu/goini/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230511479,"owners_count":18237657,"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":[],"created_at":"2024-11-13T22:11:52.251Z","updated_at":"2024-12-19T23:14:41.535Z","avatar_url":"https://github.com/widuu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"goini\t\n========\n[![Build Status](https://travis-ci.org/widuu/goini.svg?branch=master)](https://travis-ci.org/widuu/goini)\n\n**[The official website](http://www.widuu.com)**\n##描述\n\n使用goini更简单的读取go的ini配置文件以及根据特定格式的各种配置文件。\n\n##安装方法\n\n\tgp get github.com/widuu/goini\n\n##使用方法\n\n\u003eini配置文件格式样列\n\n\t[database]\n\tusername = root\n\tpassword = password\n\thostname = localhost\n\t\n\t[admin]\n\tusername = root\n\tpassword = password\n\t\n\t[nihao]\n\tusername = root\n\tpassword = password\n\n\u003e初始化\n\n\tconf := goini.SetConfig(\"./conf/conf.ini\") //goini.SetConfig(filepath) 其中filepath是你ini 配置文件的所在位置\n\n\u003e获取单个配置信息\n\n\tusername := conf.GetValue(\"database\", \"username\") //database是你的[section]，username是你要获取值的key名称\n\tfmt.Println(username) //root\n\n\u003e删除一个配置信息\n\n\tconf.DeleteValue(\"database\", \"username\")\t//username 是你删除的key\n\tusername = conf.GetValue(\"database\", \"username\")\n\tif len(username) == 0 {\n\t\tfmt.Println(\"username is not exists\") //this stdout username is not exists\n\t}\n\n\u003e添加一个配置信息\n\n\tconf.SetValue(\"database\", \"username\", \"widuu\")\n\tusername = conf.GetValue(\"database\", \"username\")\n\tfmt.Println(username) //widuu 添加配置信息如果存在[section]则添加或者修改对应的值，如果不存在则添加section\n\n\u003e获取所有配置信息\n\n\tconf.ReadList() //返回[]map[string]map[string]string的格式 即setion=\u003ekey-\u003evalue\n\n---\n\ngoini\n========\n\n\n##About\n\n使用goini更简单的读取go的ini配置文件以及根据特定格式的各种配置文件。\n\n##install \n\n\tgp get github.com/widuu/goini\n\n##use example\n\n\u003econf.ini\n\n\t[database]\n\tusername = root\n\tpassword = password\n\thostname = localhost\n\t\n\t[admin]\n\tusername = root\n\tpassword = password\n\t\n\t[nihao]\n\tusername = root\n\tpassword = password\n\n\u003einitialize\n\n\tconf := goini.SetConfig(\"./conf/conf.ini\") //goini.SetConfig(filepath) filepath = directory+file\n\n\u003eTo obtain a single configuration information\n\n\tusername := conf.GetValue(\"database\", \"username\") //username is your key you want get the value\n\tfmt.Println(username) //root\n\n\u003eTo delete a configuration information\n\n\tconf.DeleteValue(\"database\", \"username\")\t//username is your delete the key\n\tusername = conf.GetValue(\"database\", \"username\")\n\tif len(username) == 0 {\n\t\tfmt.Println(\"username is not exists\") //this stdout username is not exists\n\t}\n\n\u003eAdd a configuration information\n\n\tconf.SetValue(\"database\", \"username\", \"widuu\")\n\tusername = conf.GetValue(\"database\", \"username\")\n\tfmt.Println(username) //widuu Adding/section configuration information if there is to add or modify the value of the corresponding, if there is no add section\n\n\u003eGet all the configuration information\n\n\tconf.ReadList() //return []map[string]map[string]string  example:setion=\u003ekey-\u003evalue\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Fgoini","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiduu%2Fgoini","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiduu%2Fgoini/lists"}