New returns an initialized Viper instance.
()
| 192 | |
| 193 | // New returns an initialized Viper instance. |
| 194 | func 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, |