Connect and share knowledge within a single location that is structured and easy to search. golanggolang YAMLgolangyaml . A good configuration system will support default values. One important thing to recognize when working with ENV variables is that the Secure Remote Providers are implemented with github.com/bketelsen/crypt, AllKeys returns all keys holding a value, regardless of where they are set. This programming tutorial introduces Golang's viper bundle with Go code [] There is no configuration or type User struct { Id string `json:"id"` Name string `json:"name"` Password string `json:"password"` } // an instance of our User struct user := User {Id: "ID001", Name: "LanKa", Password: "123465"} convert instance ca . // name of config file (without extension), // REQUIRED if the config file does not have the extension in the name, // call multiple times to add many search paths, // optionally look for config in the working directory, // Config file not found; ignore error if desired, // Config file was found but another error was produced, // Config file found and successfully parsed, // writes current config to predefined path set by 'viper.AddConfigPath()' and 'viper.SetConfigName', // will error since it has already been written. you have to change the delimiter: Viper also supports unmarshaling into embedded structs: Viper uses github.com/mitchellh/mapstructure under the hood for unmarshaling values which uses mapstructure tags by default. Golang YAML yaml YAML Golang . how to use Consul. Find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, INI, envfile or Java properties formats. This package is not in the latest version of its module. In Go, there are various packages to deal with utility configuration. Get can retrieve any value given the key to use. independently of it. pull the configuration from the remote provider. It will The Unmarshal function doesn't create and return Go objects , so we have to pass a reference to store the decoded content. You can 2022 TechnologyAdvice. The priority of the sources is the following: We also tell Viper the type of the config file . prefix. Like BindEnv, the value is not set when the binding method is called, but when the use of other packages that use the flag What video game is Charlie playing in Poker Face S01E07? You signed in with another tab or window. variables, flags, and remote K/V store, but you are not bound to them. AutomaticEnv is a powerful helper especially when combined with Will not overwrite the given file, if it exists. Go jsonUnmarshalnil . the correct gpg keyring. This is useful if you want to use - or something in your Viper is a complete configuration solution for Go applications including 12-Factor apps. SetDefault sets the default value for this key. but it would require weird concatenation for accessing config keys and would be less separated from the global config. keys to an extent. For example, create a Consul key/value store key MY_CONSUL_KEY with value: Of course, you're allowed to use SecureRemoteProvider also. Unmarshaljsonv. Viper requires minimal configuration so it knows where to look for config files. if err != nil { return } err = viper.Unmarshal(&config) return } How to Connect Golang App to Redis and MongoDB. There are five methods that exist to aid working config file, environment variable, remote configuration or flag. value if its not found. Provide a mechanism to set default values for your different configuration options. // but exiting and panicing is out of scope for a logging library. Internally, the NewCache function can address max-items and item-size keys directly: The resulting code is easy to test, since it's decoupled from the main config structure, Gone are the days of needing to restart a server to have a config take effect, To check if a given key exists, the IsSet() method yaml.Unmarshal YAML Golang . default values, but are overridden by configuration values retrieved from disk, Not the answer you're looking for? in bytes. This way the module can be instantiated more than once, with different configurations. thanks ~. 3 Methods to access Environment Variables in golang. Just type: go get github.com/spf13/viper to install the viper package. The pflag package can handle the flags not match it. We will learn how to convert from JSON raw data (strings or bytes) into Go types like structs, arrays, and slices, as well as unstructured data like maps and empty interfaces. hook or something ? the Set() method, ) with an immediate value, then all sub-keys of An external support that helps in this respect is not only a respite, but also very much welcome for the developers involved in building such a solution. the environment variable is case sensitive. Viper does not default to any configuration search paths leaving defaults decision A default value is not SetFs sets the filesystem to use to read configuration. A.53. etcd requires http://ip:port consul requires ip:port Viper predefines many configuration sources such as files, environment For example: Lastly, if there exists a key that matches the delimited key path, its value Read more Go programming tutorials and Golang development tips. You can vote for case sensitivity by filling out this feedback form: https://forms.gle/R6faU74qPRPAzchZ9. path is the path in the k/v store to retrieve configuration Viper is here to help with that. Like BindEnv, the value is not set when the binding method is called, but when It supports: setting defaults. Will not overwrite the current config file, if it exists. Advertisement. Teams. Using judiciously is the key. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. SafeWriteConfig - writes the current viper configuration to the predefined path. would return a string slice for the key if the key's type is inferred by The best way to do this is to initialize the folder with git init. // They are useful when debugging the system. TechnologyAdvice does not include all companies or all types of products available in the marketplace. . In all of the examples above, they demonstrate using viper in its singleton Looking to learn Go or Golang in an online course environment? has been provided. env vars). GetUint64 returns the value associated with the key as an unsigned integer. document headers). SetEnvPrefix. rev2023.3.3.43278. Is it safe to concurrently read and write to a viper? // open a goroutine to watch remote changes forever, // currently, only tested with etcd support, // unmarshal new config into our runtime config struct. For example, an application might use multiple different cache stores for different purposes: We could pass the cache name to a module (eg. Just to clarify one point (I wasted some time because of it). Step 5 - Create the SMTP Credentials. A frequently requested feature for Viper is adding more value formats and decoders. to Cobra. viper viper.GetString ("xxx"). purposes. You can also create many different vipers for use in your application. Where does this (supposedly) Gibson quote come from? However, if datastore.metric was overridden (by a flag, an environment variable, Remote Providers are searched in the order they are added. package supports are mirrored as methods on a viper. Observe in the following Golang code example that we can not only retrieve values from the environment variable, but also set them as required: We can also set new environment variables through Go code, subject to the Operating Systems permission, of course: Note that the flag package does not offer such flexibility, but the os package in the standard library offers some. with ENV: When working with ENV variables, its important to recognize that Viper Sample app.env file. It will How to unmarshall viper config to struct with dash character. Make sure that the tags AutomaticEnv is a powerful helper especially when combined with A place where magic is studied and practiced? For example, create a Consul key/value store key MY_CONSUL_KEY with value: Of course, you're allowed to use SecureRemoteProvider also. The accessor methods also accept formatted paths to deeply nested keys. default values, but are overridden by configuration values retrieved from disk, is set via an environment variable to "a b c", a call to the Get function Viper uses the following precedence order. WatchConfig starts watching a config file for changes. 12-Factor app is a methodology for building software-as-a-service (SAAS) applications. This is accomplished The following functions and methods exist: One important thing to recognize is that each Get function will return a zero secretkeyring is the filepath to your openpgp secret keyring. endpoint is the url. ConfigFileUsed returns the file used to populate the config registry. Does not include extension. Source code is as follows: For example, parsing character (dot, comma, semicolon, etc) separated strings into slices. Viper does not fix the value when applications out of the box. rest are the name of the environment variables to bind to this key. variables, flags, and remote K/V store, but you are not bound to them. SafeWriteConfigAs - writes the current viper configuration to the given filepath. We have a list of allowed GCS buckets for clients, and we moved them to our configuration file. MergeConfigMap merges the configuration from the map given with an existing config. This enables one to change a name without breaking the application. has been provided. solution for Go. Why do many companies reject expired SSL certificates as bugs in bug bounties? SupportedRemoteProviders are universally supported remote providers. You can use remote configuration in conjunction with local configuration, or If nothing happens, download GitHub Desktop and try again. ConfigParseError denotes failing to parse configuration file. If more than Minimising the environmental effects of my dyson brain. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Viper will automatically assume that the ENV variable matches the following format: prefix + "_" + the key name in ALL CAPS. (config, default or flags). When developing reusable modules, it's often useful to extract a subset of the configuration Data encoding is an important part of any programming language to encode data into JSON or decode data into String. 4. config file SetTypeByDefaultValue enables or disables the inference of a key value's MergeInConfig merges a new configuration with an existing config. panic:uri"mongodb"mongodb+srv"Golang-MongoDB,mongodb,docker,go,connection,Mongodb,Docker,Go,Connection Step 1 - Create the Database Models with GORM. " " . It helps quite a few configuration file codecs equivalent to JSON, YAML, TOML, HCL and Java properties format. ConfigFileNotFoundError denotes failing to find configuration file. Work fast with our official CLI. Hello World. To check if a given key exists, the IsSet() method Your problem trivially comes down to the fact, if the username field in your MyConfig struct is exported or not. FlagValue represents a single flag. maintains a set of configuration sources, fetches IsSet checks to see if the key has been set in any of the data locations. configuration values encrypted and have them automatically decrypted if you have The first parameter is the key name, the To learn more, see our tips on writing great answers. GetString returns the value associated with the key as a string. A: Viper is designed to be a companion . If a law is new but its interpretation is vague, can the courts directly ask the drafters the intent and official interpretation of their law? If the ENV variable name is not provided, then DecoderConfig.DecodeHook value, the default is: FlagValue is an interface that users can implement Viper will look for the ENV variable "ID". etc. Golang viper is a package that helps to provide full configuration to an application in Golang with 12-factor apps. Observe that a new list of packages related to the viper package will be added in the go.mod file. . JSON ( JavaScript Object Notation) is a simple data . Q&A for work. // read from remote config the first time. Will overwrite the given file, if it exists. key does not exist in the file. However, if datastore.metric was overridden (by a flag, an environment variable, In addition to covering the most popular programming languages today, we publish reviews and round-ups of developer tools that help devs reduce the time and money spent developing, maintaining, and debugging their applications. Create Project module. using SetEnvPrefix, you can tell Viper to use a prefix while reading from In this blog, we will learn how to load the configurations from the envfile in Golang using Viper in Go (Golang) projects. To learn more, see our tips on writing great answers. you have to change the delimiter: Viper also supports unmarshaling into embedded structs: Viper uses github.com/mitchellh/mapstructure under the hood for unmarshaling values which uses mapstructure tags by default. time a viper.Get request is made. I am Amit Shekhar, a mentor helping developers in getting high-paying tech jobs.. package from the standard library. one are provided, they will take precedence in the specified order. Why is there a voltage on my HDMI and coaxial cables? GetBool returns the value associated with the key as a boolean. Both BindEnv and AutomaticEnv will use this Read: The Best Tools for Remote Developers. Simple, lightweight, extensible, configuration management library for Go. Many Go projects are built using Viper including: Note: Viper uses Go Modules to manage dependencies. GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings. Simply tell the viper instance to watchConfig. viper Viper New Viper // viper.GetInt("count") // Viper globalViper := viper.GetViper() // Viper conf := viper.New() conf.SetConfigFile("config.yaml") . You can use your favorite format's marshaller with the config returned by AllSettings(). to the source's priority. reading from JSON, TOML, YAML, HCL, envfile and Java properties config files, live watching and re-reading of config files (optional), reading from remote config systems (etcd or Consul), and watching changes. 5. key/value store Step 6 - Setup the HTML Templates. My code is GPL licensed, can I issue a license to have my code be distributed in a specific MIT licensed project? The good news is golang allows us to write our own custom json marshaller and unmarshalers. Error returns the formatted configuration error. You can use remote configuration in conjunction with local configuration, or Unlike SetEnvKeyReplacer, it accepts a StringReplacer interface allowing you to write custom string replacing logic. with ENV: When working with ENV variables, its important to recognize that Viper to bind a set of flags to viper. Encryption is optional. Viper is a complete configuration solution for Go applications including 12-Factor apps . For example: Lastly, if there exists a key that matches the delimited key path, its value In Viper, there are a few ways to get a value depending on the values type. If you want to unmarshal configuration where the keys themselves contain dot (the default key delimiter), how to use Consul. configuration level. It is case sensitive, meaning, as the key is provided, it will use the environment key that matches the key in uppercase if given in uppercase. This way the module can be instantiated more than once, with different configurations. A Complete Guide to JSON in Golang (With Examples) In this post, we will learn how to work with JSON in Go, in the simplest way possible. sign in Both BindEnv and AutomaticEnv will use this SafeWriteConfig - writes the current viper configuration to the predefined path. Grpc+Grpc GatewayRpcRestful Apihttp2TLSgrpcRestful Api We might take a stab at implementing it in Viper v2, but despite the initial noise, it does not seem to be requested that much. Viper has the ability to bind to flags. It needs to uppercased to be "exported" for Unmarshal to decode the value into the struct. Viper viperwatchConfigViper WatchConfig() So you watched how to build beautiful Golang CLI with Cobra? Here is a quick example of how to unmarshal with viper in Go: Note that the marshalling features are typically provided by the package of the file format we want to marshall. package: Viper will read a config string (as JSON, TOML, YAML, HCL or envfile) retrieved from a path Did any DOS compatibility layers exist for any UNIX-like systems before DOS started to become outmoded? How to match a specific column position till the end of line? Suppose we want to get the values of the common Operating System environment variable called PATH. Once a Go application project has been set up properly with the required module file using the go mod init command, a go.mod file will be created. package from the standard library. rev2023.3.3.43278. This programming tutorial introduces Golangs viper package with Go code examples. independently, together they make a powerful pair to handle much of your Find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, INI, envfile or Java properties formats. You can also bind an existing set of pflags (pflag.FlagSet): The use of pflag in Viper does not preclude Let the JSON config file: testJSONConfig.json be as follows: The Go code snippet to read the JSON file is as follows: Working with other popular file formats, such as YAML, TOML, HCL, and so on, using viper is more or less similar. It returns nil if a key cannot be found. Viper is heading towards v2 and we would love to hear what you would like to see in it. It is designed to work within an application, and can handle all types of configuration needs and formats. debugging output) or transmission (e.g. Why are physically impossible and logically impossible concepts considered separate in terms of probability? the correct gpg keyring. Viper comes ready to use out of the box. Read more about the details in this blog post. WriteConfig - writes the current viper configuration to the predefined path, if exists. For have its own unique set of configurations and values. This is accomplished One important thing to recognize when working with ENV variables is that the You can also create many different vipers for use in your application. Viper supports the ability to have your application live read a config file while running. You need to set a key to Consul key/value storage with JSON value containing your desired config. It supports: Viper can be thought of as a registry for all of your applications configuration needs. Our config file is app.env, so its name is app. Viper supports JSON, TOML, YAML, HCL, INI, envfile and Java Properties files. javascript; java; . Concurrent reads and writes can cause a panic. StringReplacer applies a set of replacements to a string. Marshal & Unmarshal in golang. Installing Viper is similar to installing any package in Go. When working with multiple vipers, it is up to the user to keep track of the NewWithOptions creates a new Viper instance. the BindEnv is called. However, the viper package makes it much easier to use. Moreover, modern applications are built to deploy in different types of environments, such as in Docker, cloud infrastructures, and so forth. Remote Key/Value Store Example - Unencrypted, Remote Key/Value Store Example - Encrypted. None of the specific paths are required, but at least one path should be provided Making statements based on opinion; back them up with references or personal experience. where a configuration file is expected. "Gin CRUD RESTful API Part-5" . How is an ETF fee calculated in a trade that ends in less than a year? Can airtags be tracked from an iMac desktop, with no iPhone? Each item takes precedence over the item below it: Important: Viper configuration keys are case insensitive. and pass it to a module. Set is case-insensitive for a key. Stories about how and why companies use Go, How Go can help keep you secure by default, Tips for writing clear, performant, and idiomatic Go code, A complete introduction to building software with Go, Reference documentation for Go's standard library, Learn and network with Go developers from around the world. also implement your own required configuration source and feed it to viper. As mentioned, viper is a package that provides a complete configuration solution in a Go project. Useful for mapping an environmental variable to a key that does configuration filetype. Note that the map given may be modified. It supports: Viper can be thought of as a registry for all of your applications configuration needs. Is it safe to concurrently read and write to a viper? SetEnvKeyReplacer allows you to use a strings.Replacer object to rewrite Env koanf is a library for reading configuration from different sources in different formats in Go applications. Modules with tagged versions give importers more predictable builds. goxlsxwriter - Golang bindings for libxlsxwriter for writing XLSX (Microsoft Excel) files. Currently only etcd and Consul are supported. ENV variables are case sensitive. Not the answer you're looking for? You could then use . example of using it can be found in viper_test.go. A place where magic is studied and practiced? Does ZnSO4 + H2 at high pressure reverses to Zn + H2SO4? endpoint is the url. By using SetEnvPrefix, you can tell Viper to use a prefix while reading from the environment variables.Both BindEnv and AutomaticEnv will use this prefix. func Unmarshal. In the public interface for the viper package so applications I didn't expect that. . Default only used when no value is provided by the user via flag, config or ENV. provider. SetConfigPermissions sets the permissions for the config file. Here, we use it to retrieve the value in the Operating Systems PATH environment variable. Viper comes ready to use out of the box. as used in the Cobra library. Error returns the formatted remote provider error. For example, if we want to marshall a Go type into a YAML file, then the YAML Go package will provide the marshalling feature. Golang Viper.GetDuration - 1 examples found. Example-3: Parsing Unstructured Data. When you explicitly provide the ENV variable name (the second parameter), . SetConfigName sets name for the config file. AddConfigPath adds a path for Viper to search for the config file in. Each can read from a Why are Suriname, Belize, and Guinea-Bissau classified as "Small Island Developing States"? What is a word for the arcane equivalent of a monastery? If more arguments are provided, they will represent the env variable names that name as the config key. GetTime returns the value associated with the key as time. Unmarshal15Golang YAML natively supports three basic data types: scalars (such as strings, integers, and floats), lists, and . But on the other side, viper.AllSettings() (used by viper.Unmarshal()) can't be aware that a config value for foo is expected (unless all environment values are added to the map, which wouldn't be reasonable). Nested keys are returned with a v.keyDelim separator. style approach. // contains filtered or unexported methods. Here I'm going to talk about how to use it in golang: First, let's get a review of the API. There are ongoing discussions about making that optional. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Will not overwrite the given file, if it exists. Make sure you add all of the configPaths prior to calling WatchConfig(). Please 5.2 Hello World. Each will golang errnil. . All of the functions that viper For example if the second parameter is "id", This enables 12 factor By default empty environment variables are considered unset and will fall back to There are ongoing discussions about making that optional. Viper can access array indices by using numbers in the path. WriteConfigAs - writes the current viper configuration to the given filepath. Make it easy to tell the difference between when a user has provided a command line or config file which is the same as the default. viper go . the AllowEmptyEnv method. // (6) viper.AutomaticEnv() // (7) err = viper.ReadInConfig() // (8) if err != nil { return } err = viper.Unmarshal(&config) // (9) return // (10) } config viper . will cascade through the remaining configuration registries until found. The Golang viper package uses . 6. defaults. There is no configuration or MergeConfig merges a new configuration with an existing config. datastore.metric.protocol was defined in the defaults, Viper would also find it. independently, together they make a powerful pair to handle much of your 3. Here is an example of how to use Viper to search for and read a configuration file. GetStringSlice returns the value associated with the key as a slice of strings. UnsupportedRemoteProviderError denotes encountering an unsupported remote but empty environment variables as valid values instead of falling back. In Viper, decode hooks can be passed to the Unmarshal and UnmarshalKey functions: viper.Unmarshal(&config, viper.DecodeHook(hookFunc)) // OR viper.UnmarshalKey("key", &config, viper.DecodeHook(hookFunc)) Viper also comes with a set of default hooks which can be overridden by passing a custom decode hook to one of the above functions . Unlike SetEnvKeyReplacer, it accepts a StringReplacer interface allowing you to write custom string replacing logic. In this video tutorial we are going to look at the Viper library that allows for Go application configuration over a .env file or the standard environment va. it is accessed. Sometimes, configuration files are written in a separate configuration file in one of the many different available formats, such as JSON. BindFlagValues binds a full FlagValue set to the configuration, using each flag's long value will be read each time it is accessed. configuration from the K/V store, which means that you can store your // any approach to require this configuration into your program. reading from JSON, TOML, YAML, HCL, envfile and Java properties config files. // retrieve values from viper instead of pflag, // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv", // Config's format: "json", "toml", "yaml", "yml", // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv". The viper package is fully equipped to read and extract information stored there. If so, how close was it? If you're unfamiliar with this style, yaml.v3yamlviperyamlYAML.yaml.v3 yaml viper yaml YAML . crypt has a command-line helper that you can use to put configurations in your (etcd Consul). Viper is here to help with that. Summary. Are you sure you want to create this branch? Logger is a unified interface for various logging use cases and practices, including: Option configures Viper using the functional options paradigm popularized by Rob Pike and Dave Cheney. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. SetEnvPrefix defines a prefix that ENVIRONMENT variables will use. Using reflect, how do you set the value of a struct field? This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. configuration file formats; you want to focus on building awesome software. Many Go projects are built using Viper including: Note: Viper uses Go Modules to manage dependencies. Interestingly, viper also provides the feature of unmarshalling of values from configuration files to Go types such as struct, map, and so on. AddRemoteProvider(provider, endpoint, path), AddSecureRemoteProvider(provider, endpoint, path, secretkeyring), (v) AddRemoteProvider(provider, endpoint, path), (v) AddSecureRemoteProvider(provider, endpoint, path, secretkeyring), func AddRemoteProvider(provider, endpoint, path string) error, func AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error, func AllSettings() map[string]interface{}, func BindFlagValue(key string, flag FlagValue) error, func BindFlagValues(flags FlagValueSet) error, func BindPFlag(key string, flag *pflag.Flag) error, func BindPFlags(flags *pflag.FlagSet) error, func GetDuration(key string) time.Duration, func GetStringMap(key string) map[string]interface{}, func GetStringMapString(key string) map[string]string, func GetStringMapStringSlice(key string) map[string][]string, func MergeConfigMap(cfg map[string]interface{}) error, func OnConfigChange(run func(in fsnotify.Event)), func RegisterAlias(alias string, key string), func SafeWriteConfigAs(filename string) error, func SetConfigPermissions(perm os.FileMode), func SetDefault(key string, value interface{}), func SetEnvKeyReplacer(r *strings.Replacer), func Unmarshal(rawVal interface{}, opts DecoderConfigOption) error, func UnmarshalExact(rawVal interface{}, opts DecoderConfigOption) error, func UnmarshalKey(key string, rawVal interface{}, opts DecoderConfigOption) error, func WriteConfigAs(filename string) error, func (faee ConfigFileAlreadyExistsError) Error() string, func (fnfe ConfigFileNotFoundError) Error() string, func (e ConfigMarshalError) Error() string, func (pe ConfigParseError) Error() string, func DecodeHook(hook mapstructure.DecodeHookFunc) DecoderConfigOption, func EnvKeyReplacer(r StringReplacer) Option, func IniLoadOptions(in ini.LoadOptions) Option, func (rce RemoteConfigError) Error() string, func (str UnsupportedConfigError) Error() string, func (str UnsupportedRemoteProviderError) Error() string, func NewWithOptions(opts Option) *Viper, func (v *Viper) AddRemoteProvider(provider, endpoint, path string) error, func (v *Viper) AddSecureRemoteProvider(provider, endpoint, path, secretkeyring string) error, func (v *Viper) AllSettings() map[string]interface{}, func (v *Viper) AllowEmptyEnv(allowEmptyEnv bool), func (v *Viper) BindEnv(input string) error, func (v *Viper) BindFlagValue(key string, flag FlagValue) error, func (v *Viper) BindFlagValues(flags FlagValueSet) (err error), func (v *Viper) BindPFlag(key string, flag *pflag.Flag) error, func (v *Viper) BindPFlags(flags *pflag.FlagSet) error, func (v *Viper) Get(key string) interface{}, func (v *Viper) GetDuration(key string) time.Duration, func (v *Viper) GetFloat64(key string) float64, func (v *Viper) GetInt32(key string) int32, func (v *Viper) GetInt64(key string) int64, func (v *Viper) GetIntSlice(key string) []int, func (v *Viper) GetSizeInBytes(key string) uint, func (v *Viper) GetString(key string) string, func (v *Viper) GetStringMap(key string) map[string]interface{}, func (v *Viper) GetStringMapString(key string) map[string]string, func (v *Viper) GetStringMapStringSlice(key string) map[string][]string, func (v *Viper) GetStringSlice(key string) []string, func (v *Viper) GetTime(key string) time.Time, func (v *Viper) GetUint16(key string) uint16, func (v *Viper) GetUint32(key string) uint32, func (v *Viper) GetUint64(key string) uint64, func (v *Viper) InConfig(key string) bool, func (v *Viper) MergeConfig(in io.Reader) error, func (v *Viper) MergeConfigMap(cfg map[string]interface{}) error, func (v *Viper) MustBindEnv(input string), func (v *Viper) OnConfigChange(run func(in fsnotify.Event)), func (v *Viper) ReadConfig(in io.Reader) error, func (v *Viper) RegisterAlias(alias string, key string), func (v *Viper) SafeWriteConfigAs(filename string) error, func (v *Viper) Set(key string, value interface{}), func (v *Viper) SetConfigPermissions(perm os.FileMode), func (v *Viper) SetDefault(key string, value interface{}), func (v *Viper) SetEnvKeyReplacer(r *strings.Replacer), func (v *Viper) SetTypeByDefaultValue(enable bool), func (v *Viper) Unmarshal(rawVal interface{}, opts DecoderConfigOption) error, func (v *Viper) UnmarshalExact(rawVal interface{}, opts DecoderConfigOption) error, func (v *Viper) UnmarshalKey(key string, rawVal interface{}, opts DecoderConfigOption) error, func (v *Viper) WatchRemoteConfig() error, func (v *Viper) WatchRemoteConfigOnChannel() error, func (v *Viper) WriteConfigAs(filename string) error, https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html, https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis, reading from JSON, TOML, YAML, HCL, envfile and Java properties config files, live watching and re-reading of config files (optional), reading from remote config systems (etcd or Consul), and watching changes.