MCPcopy
hub / github.com/spf13/viper / New

Function New

viper.go:194–220  ·  viper.go::New

New returns an initialized Viper instance.

()

Source from the content-addressed store, hash-verified

192
193// New returns an initialized Viper instance.
194func New() *Viper {
195 v := new(Viper)
196 v.keyDelim = "."
197 v.configName = "config"
198 v.configPermissions = os.FileMode(0o644)
199 v.fs = afero.NewOsFs()
200 v.config = make(map[string]any)
201 v.parents = []string{}
202 v.override = make(map[string]any)
203 v.defaults = make(map[string]any)
204 v.kvstore = make(map[string]any)
205 v.pflags = make(map[string]FlagValue)
206 v.env = make(map[string][]string)
207 v.aliases = make(map[string]string)
208 v.typeByDefValue = false
209 v.logger = slog.New(&discardHandler{})
210
211 codecRegistry := NewCodecRegistry()
212
213 v.encoderRegistry = codecRegistry
214 v.decoderRegistry = codecRegistry
215
216 v.experimentalFinder = features.Finder
217 v.experimentalBindStruct = features.BindStruct
218
219 return v
220}
221
222// Option configures Viper using the functional options paradigm popularized by Rob Pike and Dave Cheney.
223// If you're unfamiliar with this style,

Callers 15

TestGetConfigFileFunction · 0.85
TestReadInConfigFunction · 0.85
TestDefaultFunction · 0.85
TestUnmarshalingFunction · 0.85
TestUnmarshalExactFunction · 0.85
TestOverridesFunction · 0.85
TestDefaultPostFunction · 0.85
TestAliasesFunction · 0.85
TestAliasInConfigFileFunction · 0.85
TestYMLFunction · 0.85
TestJSONFunction · 0.85
TestTOMLFunction · 0.85

Calls 1

NewCodecRegistryFunction · 0.85

Tested by 15

TestGetConfigFileFunction · 0.68
TestReadInConfigFunction · 0.68
TestDefaultFunction · 0.68
TestUnmarshalingFunction · 0.68
TestUnmarshalExactFunction · 0.68
TestOverridesFunction · 0.68
TestDefaultPostFunction · 0.68
TestAliasesFunction · 0.68
TestAliasInConfigFileFunction · 0.68
TestYMLFunction · 0.68
TestJSONFunction · 0.68
TestTOMLFunction · 0.68