aboutsummaryrefslogtreecommitdiff
path: root/loader_test.go
blob: acd689d1c5495c42ac8c4a1ee5b9f19e4ceba3b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package conf_test

import (
	"fmt"

	"go.neonxp.ru/conf"
)

func ExampleLoad() {
	config := `
		key = "value";
		group "test" {
			key = 123;
		}
	`

	cfg, err := conf.Load("example", []byte(config))
	if err != nil {
		panic(err)
	}

	fmt.Println("key =", cfg.Get("key")[0])
	group := cfg.Commands("group")
	for _, gr := range group {
		fmt.Println("key =", gr.Body.Get("key")[0])
	}
	// Output:
	// key = value
	// key = 123
}