MCPcopy Create free account
hub / github.com/gookit/config / Example_exportConfig

Function Example_exportConfig

config_test.go:119–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119func Example_exportConfig() {
120 // Notice: before dump please set driver encoder
121 // SetEncoder(Yaml, yaml.Encoder)
122
123 ClearAll()
124 // load from string
125 err := LoadStrings(JSON, `{
126"name": "app",
127"age": 34
128}`)
129 if err != nil {
130 panic(err)
131 }
132
133 buf := new(bytes.Buffer)
134 _, err = DumpTo(buf, JSON)
135 if err != nil {
136 panic(err)
137 }
138
139 fmt.Printf("%s", buf.String())
140
141 // Output:
142 // {"age":34,"name":"app"}
143}
144
145func BenchmarkGet(b *testing.B) {
146 err := LoadStrings(JSON, jsonStr)

Callers

nothing calls this directly

Calls 4

ClearAllFunction · 0.85
LoadStringsFunction · 0.85
DumpToFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…