Ecosyste.ms: Packages

An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.3% on proxy.golang.org

proxy.golang.org : github.com/nil-go/konf

Package konf provides a general-purpose configuration API and abstract interfaces to back that API. Packages in the Go ecosystem can depend on this package, while callers can load configuration from whatever source is appropriate. It defines a type, Config, which provides a method Config.Unmarshal for loading configuration under the given path into the given object. Each Config is associated with multiple Loader(s), Which load configuration from a source, such as file, environment variables etc. There is a default Config accessible through top-level functions (such as Unmarshal and Get) that call the corresponding Config methods. Configuration is hierarchical, and the path is a sequence of keys that separated by delimiter. The default delimiter is `.`, which makes configuration path like `parent.child.key`. After creating a Config, you can load configuration from multiple Loader(s) using Config.Load. Each loader takes precedence over the loaders before it. As long as the configuration has been loaded, it can be used in following code to get or unmarshal configuration, even for loading configuration from another source. For example, it can read config file path from environment variables, and then use the file path to load configuration from file system. Config.Watch watches and updates configuration when it changes, which leads Config.Unmarshal always returns latest configuration. You may use Config.OnChange to register a callback if the value of any path have been changed. It could push the change into application objects instead pulling the configuration periodically. When decoding to a struct, konf will use the field name by default to perform the mapping. For example, if a struct has a field "Username" then konf will look for a key in the source value of "username" (case insensitive). You can change the behavior of konf by using struct tags. The default struct tag that konf looks for is "konf" but you can customize it using DecoderConfig. To rename the key that konf looks for, use the "konf" tag and set a value directly. For example, to change the "username" example above to "user": Embedded structs are treated as if they're another field with that name. By default, the two structs below are equivalent when decoding with konf: This would require an input that looks like below: If your "person" value is NOT nested, then you can append ",squash" to your tag value and konf will treat it as if the embedded struct were part of the struct directly. Example: Now the following input would be accepted: Since unexported (private) struct fields cannot be set outside the package where they are defined, the decoder will simply skip them. For this output type definition: Using this map as input: The following struct will be decoded:

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/nil-go/konf
Keywords: appconfig, config, config-loader, configuration, configuration-file, configuration-loader, environment-variables, flags, go, golang, minimalist, pflag
License: MIT
Latest release: 6 months ago
First release: about 1 year ago
Namespace: github.com/nil-go
Stars: 6 on GitHub
Forks: 1 on GitHub
Total Commits: 95
Committers: 2
Average commits per author: 47.5
Development Distribution Score (DDS): 0.116
More commit stats: commits.ecosyste.ms
See more repository details: repos.ecosyste.ms
Last synced: 23 days ago

    Loading...
    Readme
    Loading...