-
Notifications
You must be signed in to change notification settings - Fork 41
/
doc.go
45 lines (41 loc) · 1.11 KB
/
doc.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Package goconf provides configuraton read and write implementations.
Examples:
package main
import (
"fmt"
"github.com/Terry-Mao/goconf"
"time"
)
type TestConfig struct {
ID int `goconf:"core:id"`
Col string `goconf:"core:col"`
Ignore int `goconf:"-"`
Arr []string `goconf:"core:arr:,"`
Test time.Duration `goconf:"core:t_1:time"`
Buf int `goconf:"core:buf:memory"`
Arr1 []int `goconf:"core:arr1:,"`
M map[int]string`goconf:"core:m:,"`
}
func main() {
conf := goconf.New()
if err := conf.Parse("./examples/conf_test.txt"); err != nil {
panic(err)
}
core := conf.Get("core")
if core == nil {
panic("no core section")
}
id, err := core.Int("id")
if err != nil {
panic(err)
}
fmt.Println(id)
tf := &TestConfig{}
if err := conf.Unmarshal(tf); err != nil {
panic(err)
}
fmt.Println(tf.ID)
}
*/
package goconf