Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 14 days ago
JSON representation

Parse (sort of) INI files like "flag" package in Go.

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
}
```