MCPcopy Create free account
hub / github.com/DoNewsCode/core / NewConfig

Function NewConfig

config/config.go:75–89  ·  view source on GitHub ↗

NewConfig creates a new *KoanfAdapter.

(options ...Option)

Source from the content-addressed store, hash-verified

73
74// NewConfig creates a new *KoanfAdapter.
75func NewConfig(options ...Option) (*KoanfAdapter, error) {
76 adapter := KoanfAdapter{delimiter: "."}
77
78 for _, f := range options {
79 f(&adapter)
80 }
81
82 adapter.K = koanf.New(adapter.delimiter)
83
84 if err := adapter.Reload(); err != nil {
85 return nil, err
86 }
87
88 return &adapter, nil
89}
90
91// Reload reloads the whole configuration stack. It reloads layer by layer, so if
92// an error occurred, Reload will return early and abort the rest of the

Callers 8

ProvideConfigFunction · 0.92
TestProvideOpentracingFunction · 0.92
Example_minimumFunction · 0.92
TestKoanfAdapter_WatchFunction · 0.85
TestKoanfAdapter_ReloadFunction · 0.85
setupFunction · 0.85
TestModule_WatchFunction · 0.85

Calls 1

ReloadMethod · 0.95

Tested by 7

TestProvideOpentracingFunction · 0.74
Example_minimumFunction · 0.74
TestKoanfAdapter_WatchFunction · 0.68
TestKoanfAdapter_ReloadFunction · 0.68
setupFunction · 0.68
TestModule_WatchFunction · 0.68