You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
/* |
|
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
|
|
|