https://github.com/lucasepe/mini
Parse (sort of) INI files like "flag" package in Go.
https://github.com/lucasepe/mini
configuration flag golang ini parser
Last synced: over 1 year ago
JSON representation
Parse (sort of) INI files like "flag" package in Go.
- Host: GitHub
- URL: https://github.com/lucasepe/mini
- Owner: lucasepe
- License: apache-2.0
- Created: 2023-10-10T05:41:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-24T15:45:09.000Z (over 2 years ago)
- Last Synced: 2025-01-23T16:47:34.296Z (over 1 year ago)
- Topics: configuration, flag, golang, ini, parser
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mini
Parse (sort of) INI files like "flag" package in Go.
## Example
```go
import (
"fmt"
"log"
"strings"
"github.com/lucasepe/mini"
)
func ExampleNewConf() {
data := `
width: 1600
subject: Computers,Education,Programming
[background]
art: shapes
[title]
text: Awesome Book!
color: #000000
font-size: 160
offset: 0.3
`
conf := mini.NewConf()
width := conf.Int("", "width", 1000)
height := conf.Int("", "height", 1000)
subject := conf.StringSlice("", "subject", []string{})
watermark := conf.String("", "watermark", "")
art := conf.Enum("background", "art", []string{
"color-circles",
"shapes",
"circles-grid",
"pixel-hole",
"dots-wawe",
"contour-line",
"dot-line",
"warp",
})
err := conf.Parse(strings.NewReader(data))
if err != nil {
log.Fatal(err)
}
fmt.Println(*width)
fmt.Println(*height)
fmt.Println(*subject)
fmt.Println(*watermark)
fmt.Println(*art)
// Output:
// 1600
// 1000
// [Computers,Education,Programming]
//
// shapes
}
```