Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evanxg852000/goini
A very simple go package for parsing init files ✨🐢🚀✨
https://github.com/evanxg852000/goini
Last synced: about 13 hours ago
JSON representation
A very simple go package for parsing init files ✨🐢🚀✨
- Host: GitHub
- URL: https://github.com/evanxg852000/goini
- Owner: evanxg852000
- License: mit
- Created: 2020-02-16T12:36:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-07T11:28:37.000Z (over 4 years ago)
- Last Synced: 2024-04-16T00:19:49.589Z (7 months ago)
- Language: Go
- Homepage: https://github.com/evanxg852000
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## GoIni
A very simple go package for parsing init files
[![Build Status](https://travis-ci.com/evanxg852000/goini.svg?branch=master)](https://travis-ci.com/evanxg852000/goini)
```go
package mainimport (
"fmt"
"strings"goini "github.com/evanxg852000/goini"
)const config string = `
; last modified by John Doe
name=John Doe
age= 23[owner]
name=John Doe
organization=Acme Widgets Inc.[database]
; server IP address in case ...
server=192.0.2.62
port=9080
file="payroll.dat"
`func main() {
// parse an ini file
f, err := goini.NewIniFile(strings.NewReader(config))
if err != nil {
fmt.Println("Parser Error ", err)
}// currently at root section
fmt.Println(f.Get("name")) // John Doef.MoveSection("database") // navigate to database section
fmt.Println(f.Get("server")) // 192.0.2.62
fmt.Println(f.Get("port")) // 9080
fmt.Println(f.Get("organization")) // empty as organization is in another sectionf.MoveSection("owner") // navigate to owner section
fmt.Println(f.Get("organization")) // Acme Widgets Inc.f.ResetSection() // navigate back to root section
fmt.Println(f.Get("age")) // 23}
```