Debian Codegraph @

parsers/kdl/kdl.go

raw
1 // Package kdl implements a koanf.Parser that parses KDL bytes as conf maps.
2 package kdl
3
4 import (
5 kdl "github.com/sblinch/kdl-go"
6 )
7
8 // KDL implements a KDL parser.
9 type KDL struct{}
10
11 // Parser returns a KDL Parser.
12 func Parser() *KDL {
13 return &KDL{}
14 }
15
16 // Unmarshal parses the given KDL bytes.
17 func (p *KDL) Unmarshal(b []byte) (map[string]any, error) {
18 var o map[string]any
19 err := kdl.Unmarshal(b, &o)
20 return o, err
21 }
22
23 // Marshal marshals the given config map to KDL bytes.
24 func (p *KDL) Marshal(o map[string]any) ([]byte, error) {
25 return kdl.Marshal(o)
26 }