MCPcopy Create free account
hub / github.com/apache/dubbo-go / GetConfigResolver

Function GetConfigResolver

loader.go:371–401  ·  view source on GitHub ↗

GetConfigResolver get config resolver

(conf *loaderConf)

Source from the content-addressed store, hash-verified

369
370// GetConfigResolver get config resolver
371func GetConfigResolver(conf *loaderConf) *koanf.Koanf {
372 var (
373 k *koanf.Koanf
374 err error
375 )
376 if len(conf.suffix) <= 0 {
377 conf.suffix = string(file.YAML)
378 }
379 if len(conf.delim) <= 0 {
380 conf.delim = "."
381 }
382 bytes := conf.bytes
383 if len(bytes) <= 0 {
384 panic(errors.New("bytes is nil,please set bytes or file path"))
385 }
386 k = koanf.New(conf.delim)
387
388 switch conf.suffix {
389 case "yaml", "yml":
390 err = k.Load(rawbytes.Provider(bytes), yaml.Parser())
391 case "json":
392 err = k.Load(rawbytes.Provider(bytes), json.Parser())
393 default:
394 err = errors.Errorf("no support %s file suffix", conf.suffix)
395 }
396
397 if err != nil {
398 panic(err)
399 }
400 return resolvePlaceholder(k)
401}
402
403// resolvePlaceholder replace ${xx} with real value
404func resolvePlaceholder(resolver *koanf.Koanf) *koanf.Koanf {

Callers 3

LoadFunction · 0.70
MergeConfigMethod · 0.70
buildKoanfFromBytesFunction · 0.70

Calls 4

resolvePlaceholderFunction · 0.70
ParserMethod · 0.65
ErrorfMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected