diff options
| author | 2026-02-22 20:15:50 +0300 | |
|---|---|---|
| committer | 2026-02-22 20:15:50 +0300 | |
| commit | db8bb97dfa2dacef002a1f349ea970d76fee4fc9 (patch) | |
| tree | 7de11be3a01a6ef83a218dc98d90586dd1afb09a /example | |
| parent | Добавил утилитарные функции для моделей (diff) | |
| download | conf-0.0.4.tar.gz conf-0.0.4.tar.bz2 conf-0.0.4.tar.xz conf-0.0.4.zip | |
Refactoringv0.0.4
Diffstat (limited to 'example')
| -rw-r--r-- | example/file2.conf | 7 | ||||
| -rw-r--r-- | example/main.go | 15 |
2 files changed, 20 insertions, 2 deletions
diff --git a/example/file2.conf b/example/file2.conf new file mode 100644 index 0000000..b22f06b --- /dev/null +++ b/example/file2.conf @@ -0,0 +1,7 @@ +rss = "https://neonxp.ru/feed/"; +db_file = $XDG_DATA_HOME "/pose/pose.db"; + +telegram { + token = "279146841:AAsome_secret_token_M"; + groups = "-1003888840756"; +} diff --git a/example/main.go b/example/main.go index 6e0c8b8..c42ab3b 100644 --- a/example/main.go +++ b/example/main.go @@ -4,13 +4,24 @@ import ( "fmt" "go.neonxp.ru/conf" + "go.neonxp.ru/conf/visitor" ) func main() { - out, err := conf.LoadFile("./file.conf") + cfg := conf.New() + if err := cfg.LoadFile("./example/file2.conf"); err != nil { + panic(err) + } + + pr := visitor.NewDefault() + if err := cfg.Process(pr); err != nil { + panic(err) + } + + tok, err := pr.Get("telegram.token") if err != nil { panic(err) } - fmt.Println(out) + fmt.Println(tok.String()) } |
