https://github.com/goindow/ini
Package ini 封装了一个 .ini 格式文件读取器
https://github.com/goindow/ini
ini
Last synced: about 1 month ago
JSON representation
Package ini 封装了一个 .ini 格式文件读取器
- Host: GitHub
- URL: https://github.com/goindow/ini
- Owner: goindow
- Created: 2019-03-14T05:52:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-27T08:44:54.000Z (about 6 years ago)
- Last Synced: 2025-01-21T16:23:15.332Z (3 months ago)
- Topics: ini
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ini
Package ini 封装了一个 .ini 格式文件读取器## 特性
- 注释符 ";"、"#"
- 键值分割符 "="
- 支持 section,在 [section] 后的内容都属于该 section,默认的 section 为 default
- 重复定义 section,不同键会追加到该 section 中,相同则后者覆盖前者## 索引
- [Read](#Read)### 测试数据
```
; test-case-0@Annotation ";"
# test-case-1@Annotation "#"# test-case-2@Default Section
a = 1
# test-case-3@Space
b = 2
# test-case-4@Multiple =
c = 1 + 1 = 2[user]
name = hyb
age = 18[profile]
github = github.com/goindow
email = [email protected]# test-case-5@Repetitive Section
[user]
gender = male
# test-case-6@Repetitive Item
age = 99
```### 使用
```go
import (
"github.com/goindow/ini"
)
```### Read
- 如果 err != nil,则返回值一个空 map
```go
file := ""if conf, err := ini.read(file); err != nil {
fmt.Println(conf)
}// Output:
// map[default:map[a:1 b:2 c:1 + 1 = 2] user:map[gender:male name:hyb age:99] profile:map[email:[email protected] github:github.com/goindow]]
```