This way the module can be instantiated more than once, with different configurations. modified, and redistributed. The good news is golang allows us to write our own custom json marshaller and unmarshalers. How can we prove that the supernatural or paranormal doesn't exist? 4. config file 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. Can be called multiple times to define multiple search paths. WriteConfig - writes the current viper configuration to the predefined path, if exists. Initialize the GoLinuxCloud module of the program. SetConfigType sets the type of the configuration returned by the I think i am making a silly mistake, please share your thoughts on the same. Will not overwrite the current config file, if it exists. , stage . Q&A for work. Viper requires minimal configuration so it knows where to look for config files. provides this. To achieve this: but empty environment variables as valid values instead of falling back. remote source, e.g. Viper has full support for environment variables. Golang (also known as Go) is a statically typed, compiled programming language with C-like syntax. By If matching env vars are found, they are loaded into Viper. The accessor methods also accept formatted paths to deeply nested keys. Read more about the details in this blog post. debugging output) or transmission (e.g. 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. Viper does not default to any configuration search paths leaving defaults decision See the crypt documentation for examples of how to set encrypted values, or Provide a mechanism to set default values for your different configuration options. to an application. how to use Consul. GetTime returns the value associated with the key as time. Why are physically impossible and logically impossible concepts considered separate in terms of probability? About the viper package: Viper is used to find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, INI, envfile, or Java properties formats. You signed in with another tab or window. required for a key, but its useful in the event that a key hasn't been set via and easier to reuse (for the same reason). Teams. Step 3 - Generate and Verify the Password. SetConfigName sets name for the config file. "json". "myapp" To retrieve a config file called myapp.json from /configs/myapp.json For example, if values from the following sources were loaded: The resulting config will have the following values: Note: Vipers are not safe for concurrent Get() and Set() operations. and read it in the remote configuration registry. It supports: Viper can be thought of as a registry for all of your applications configuration needs. Grpc+Grpc GatewayRpcRestful Apihttp2TLSgrpcRestful Api If you're unfamiliar with this style, Make sure you add all of the configPaths prior to calling WatchConfig(). K/V store. GetDuration returns the value associated with the key as a duration. Next, set up the git origin using git remote add origin ORIGIN_URL, then initialize the project with go mod init. IsSet is case-insensitive for a key. if your prefix is "spf", the env registry will look for env Using reflect, how do you set the value of a struct field? The first parameter is the key name, the Viper supports JSON, TOML, YAML, HCL, INI, envfile and Java Properties files. Connect and share knowledge within a single location that is structured and easy to search. For example, if we want to marshall a Go type into a YAML file, then the YAML Go package will provide the marshalling feature. Here is a quick example of how to unmarshal with viper in Go: type configType struct { InstallAt string Version string StaticPath string } var config configType err := viper.Unmarshal(&config) if err != nil { fmt.Println("Unmarshalling failed!") . Viper is a complete configuration solution for Go applications including 12-Factor apps. When called, Viper will check for an environment variable any Where type company struct has a slice of type employee struct. configuration from the K/V store, which means that you can store your Alternatively, you can use EnvKeyReplacer with NewWithOptions factory function. override, flag, env, config file, key/value store, default. What is a word for the arcane equivalent of a monastery? When building a modern application, you dont want to worry about Specifically, Viper supports Pflags You can vote for case sensitivity by filling out this feedback form: https://forms.gle/R6faU74qPRPAzchZ9. Using judiciously is the key. For example, if a key has a default value of []string{} and the same key Create config file containing environment variables. golang:) 1> Uvelichitel.. Get 5. key/value store It supports: Viper can be thought of as a registry for all of your applications configuration needs. the environment variable is case sensitive. I know I was doing something silly. FlagValueSet is an interface that users can implement OnConfigChange sets the event handler that is called when a config file changes. NewCache("cache1")), GetUint16 returns the value associated with the key as an unsigned integer. 5.2 Hello World. 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. SafeWriteConfig - writes the current viper configuration to the predefined path. In this blog, we will learn how to load the configurations from the envfile in Golang using Viper in Go (Golang) projects. Read more about the details in this blog post. It is designed to work within an application, and can handle all types of configuration needs and formats. It is designed to work within an application, and can handle all types of configuration needs and formats. Each will Will overwrite the current config file, if it exists. Viper will check in the following order: In this situation, the features provided by the viper package can be quite helpful. In all of the examples above, they demonstrate using viper in its singleton example, if the following JSON file is loaded: Viper can access a nested field by passing a . Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Golang YAML yaml YAML Golang . New returns an initialized Viper instance. There is no configuration or There are ongoing discussions about making that optional. configuration from the K/V store, which means that you can store your Learn more about Teams Connect and share knowledge within a single location that is structured and easy to search. SupportedRemoteProviders are universally supported remote providers. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. example of using it can be found in viper_test.go. hook or something ? If there is an error binding an environment variable, MustBindEnv will variables, flags, and remote K/V store, but you are not bound to them. BindFlagValue binds a specific key to a FlagValue. Like BindEnv, the value is not set when the binding method is called, but when package: Viper will read a config string (as JSON, TOML, YAML, HCL or envfile) retrieved from a path Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. ( https://youtu.be/SSRIn5DAmyw ) Time to understand how to create a fantastic configuration for i. // contains filtered or unexported fields. Read more Go programming tutorials and Golang development tips. . If so, how close was it? ConfigMarshalError happens when failing to marshal the configuration. treats ENV variables as case sensitive. GetIntSlice returns the value associated with the key as a slice of int values. In this case, the location is given by the input path argument. Best Online Courses to Learn Go and Golang, Go programming tutorials and Golang development tips. You A.53. has been provided. not match it. For check for an environment variable with a name matching the key uppercased and It returns nil if a key cannot be found. The pflag package can handle the flags maintains a set of configuration sources, fetches Connect and share knowledge within a single location that is structured and easy to search. GetStringSlice returns the value associated with the key as a slice of strings. The viper library, in this respect, can entirely replace the flag package, which provides provisions for developing UNIX systems, such as command line utilities. Will not overwrite the current config file, if it exists. It supports numerous configuration file formats such as JSON, YAML, TOML, HCL and Java properties format. Viper comes ready to use out of the box. Both BindEnv and AutomaticEnv will use this You can handle the specific case where no config file is found like this: NOTE [since 1.6]: You can also have a file without an extension and specify the format programmaticaly. GetStringMapString returns the value associated with the key as a map of strings. For yaml.Unmarshal YAML Golang . has been provided. different config file, key value store, etc. and formats. However, the viper package makes it much easier to use. SetEnvKeyReplacer sets the strings.Replacer on the viper object You can look at JSON and dealing with unexported fields to understand more on why the json package needs it. This is already available in Viper using mapstructure decode hooks. References. When called, Viper will check for an environment variable any 6. defaults. Why are Suriname, Belize, and Guinea-Bissau classified as "Small Island Developing States"? 2. flags ncdu: What's going on with this second size column? ConfigFileUsed returns the file used to populate the config registry. The first parameter is the key name, the // 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". Go jsonUnmarshalnil . When building a modern application, you dont want to worry about Note that the map given may be modified. Viper does not fix the value when AllSettings merges all settings and returns them as a map[string]interface{}. Every capability of viper may not be required at the moment, but that should not stop one from using some of its features. GetUint returns the value associated with the key as an unsigned integer. in a Key/Value store such as etcd or Consul. Will not overwrite the given file, if it exists. Many Go projects are built using Viper including Hugo, Docker Notary, Mercury. Get has the behavior of returning the value associated with the first The viper bundle is hottest amongst them in offering an entire configuration answer of an utility. You can use remote configuration in conjunction with local configuration, or 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. javascript; java; . Viper is a complete configuration solution for Go applications including 12-Factor apps. Secure Remote Providers are implemented with github.com/bketelsen/crypt, AllKeys returns all keys holding a value, regardless of where they are set. to an application. Making statements based on opinion; back them up with references or personal experience. application foundation needs. InConfig checks to see if the given key (or an alias) is in the config file. Step 6 - Setup the HTML Templates. We can create our own type alias for int type and add a custom marshaller and unmarshaler for our json this way we can check our data and convert our string to int before unmarshal To make a field exportable, just ensure that you capitalize it! configuration values encrypted and have them automatically decrypted if you have When working with multiple vipers, it is up to the user to keep track of the UnsupportedRemoteProviderError denotes encountering an unsupported remote It will In Golang, struct data is converted into JSON and JSON data to string with Marshal () and Unmarshal () method. Errors if no predefined path. Viper predefines many configuration sources such as files, environment Managing and maintaining configuration for a big and complicated application such as building a server application or any other application which depends a lot on user manipulation of configurations is not an easy task. In Go, there are many packages to handle application configuration. Step 7 - Create the Controller Functions. Do new devs get fired if they can't solve a certain bug? Errors if no predefined path. values to populate those, and provides them according GetInt returns the value associated with the key as an integer. NewCache("cache1")), Disconnect between goals and daily tasksIs it me, or the industry? Viper can access array indices by using numbers in the path. the AllowEmptyEnv method. Each can read from a Viper viperwatchConfigViper WatchConfig() Did this satellite streak past the Hubble Space Telescope so close that it was out of focus? secretkeyring is the filepath to your openpgp secret keyring. Alternative to viper. and pass it to a module. JSONTOMLYAMLHCLenvfile Java . AutomaticEnv is a powerful helper especially when combined with Acidity of alcohols and basicity of amines. It will apply the following rules. A place where magic is studied and practiced? Viper uses the following precedence order. also implement your own required configuration source and feed it to viper. Viper . initialization needed to begin using Viper. viper viper.GetString ("xxx"). Viper is heading towards v2 and we would love to hear what you would like to see in it. and easier to reuse (for the same reason). These are the top rated real world Golang examples of github.com/spf13/viper.Viper.GetDuration extracted from open source . by a calling a convenience function provided by the pflag package called AutomaticEnv makes Viper check if environment variables match any of the existing keys and pass it to a module. YAML (YAML Ain't Markup Language) is a human-readable data-serialization language. the use of other packages that use the flag Remote Key/Value Store Example - Unencrypted, Remote Key/Value Store Example - Encrypted. If more than E.g. This means that it effectively reuses the JSON struct tags as well as the custom JSON . Viper provides two Go interfaces to bind other flag systems if you dont use Pflags. go31api (2022) 31httpapihttpgrpcjwt g The priority of the sources is the following: Looking to learn Go or Golang in an online course environment? The pflag package can handle the flags If you want to work with viper then replace : Thanks for contributing an answer to Stack Overflow! Learn more. UnsupportedConfigError denotes encountering an unsupported Viper has full support for environment variables. rest are the name of the environment variables to bind to this key. Provide an alias system to easily rename parameters without breaking existing code. How is an ETF fee calculated in a trade that ends in less than a year? exl - Excel binding to struct written in Go. init() function. How to unmarshall viper config to struct with dash character. Viper is a complete configuration solution for Go applications including 12-Factor apps. (etcd Consul). This programming tutorial introduces Golangs viper package with Go code examples. the use of other packages that use the flag using SetEnvPrefix, you can tell Viper to use a prefix while reading from Viper will look for the ENV variable "ID". The accessor methods also accept formatted paths to deeply nested keys. Here is an example of how to use Viper to search for and read a configuration file. Reset is intended for testing, will reset all to default settings. GetString returns the value associated with the key as a string. Create Project module. Viper uses crypt to retrieve In order to provide the best experience when using multiple sources, the decision has been made to make all keys case insensitive. AllowEmptyEnv tells Viper to consider set, WriteConfigAs - writes the current viper configuration to the given filepath. see https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html and panic. // A verbose series of information events. As for me, automatically adding defaults or environment binding with reflection is the way to go, if done carefully. defined for the flag package by importing these flags. Is it safe to concurrently read and write to a viper? I didn't expect that. // open a goroutine to watch remote changes forever, // currently, only tested with etcd support, // unmarshal new config into our runtime config struct. Marshal & Unmarshal are widely used, especially in data transmission. /etc/secrets/myring.gpg No, you will need to synchronize access to the viper yourself (for example by using the sync package). package from the standard library. to connect to a remote key/value store. sign in Sorted by: 12. 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. You could then use . 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 powered applications can read an update to a config file while running and how to use Consul. Understand that viper, after all, is a tool to be used according to the requirement of the software being developed. etc. JSON merupakan subset dari javascript.. Go menyediakan package encoding/json yang berisikan banyak fungsi untuk kebutuhan operasi json.. Pada chapter ini, kita akan belajar cara untuk konverstri string yang berbentuk json menjadi objek Go, dan sebaliknya. No, you will need to synchronize access to the viper yourself (for example by using the sync package). Developer.com features tutorials, news, and how-tos focused on topics relevant to software engineers, web developers, programmers, and product managers of development teams. Does not include extension. Golang viper is a package that helps to provide full configuration to an application in Golang with 12-factor apps. BindEnv takes one or more parameters. As a result, in order to maintain consistency across deployment, applications should be built to be open from little to high configurability. 3 Methods to access Environment Variables in golang. value if its not found. default values, but are overridden by configuration values retrieved from disk, Reading in environmental Variable Using Viper Go, How to unmarshal Golang Viper snake_case values, Idiomatic way to conditionally unmarshal a viper config (toml) into structs, viper does not unmarshal values neither from env or pflags. Viper will look for the ENV variable "ID". Viper does not fix the value when GetBool returns the value associated with the key as a boolean. pull the configuration from the remote provider. . Viper has the ability to bind to flags. For example, parsing character (dot, comma, semicolon, etc) separated strings into slices. panic:uri"mongodb"mongodb+srv"Golang-MongoDB,mongodb,docker,go,connection,Mongodb,Docker,Go,Connection Golang JSON Unmarshal () Examples. You can also bind an existing set of pflags (pflag.FlagSet): The use of pflag in Viper does not preclude It needs to uppercased to be "exported" for Unmarshal to decode the value into the struct. RemoteProvider stores the configuration necessary currently a single Viper instance only supports a single configuration file. ConfigFileAlreadyExistsError denotes failure to write new configuration file. You may need to marshal all the settings held in viper into a string rather than write them to a file. purposes. If in addition keys to an extent. If more arguments are provided, they will represent the env variable names that WatchConfig starts watching a config file for changes. Error returns the formatted configuration error. Errors if no predefined path. This means you can bind as early as you want, even in an NewWithOptions creates a new Viper instance. to use a single central repository for their configuration, the viper package The nature of simulating nature: A Q&A with IBM Quantum researcher Dr. Jamie We've added a "Necessary cookies only" option to the cookie consent popup. Where does this (supposedly) Gibson quote come from? This is a very simple example on how to implement this interface: Once your flag set implements this interface, you can simply tell Viper to bind it: To enable remote support in Viper, do a blank import of the viper/remote None of the specific paths are required, but at least one path should be provided Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. config file, environment variable, remote configuration or flag. I read config from other place, it return a map and all value is string, and can't sure what key in the Config.Mp map, so i want do it that way, but the Mp is nil after Unmarshal, how can i do it with a good way ? It We have a list of the Best Online Courses to Learn Go and Golang to help you get started. My code is GPL licensed, can I issue a license to have my code be distributed in a specific MIT licensed project? endpoint is the url. For example, create a Consul key/value store key MY_CONSUL_KEY with value: Of course, you're allowed to use SecureRemoteProvider also. Golang Viper.GetDuration - 1 examples found. . In this tutorial we will explain how to encode and decode data in Golang. AddGoFlagSet(). Viper is a complete configuration solution for Go applications including 12-Factor apps. rev2023.3.3.43278. "Gin CRUD RESTful API Part-5" . Simple, lightweight, extensible, configuration management library for Go. What video game is Charlie playing in Poker Face S01E07? Moreover, modern applications are built to deploy in different types of environments, such as in Docker, cloud infrastructures, and so forth. Viper is one of the most popular packages in the golang community. (Only supports Go1.18+) go-excel - A simple and light reader to read a relate-db-like excel as a table. K-IN . If the ENV variable name is not provided, then It supports many excellent features related to storing and retrieving configuration information sought by programmers in modern application development. Example-2: Parsing Structured Complex JSON data. one are provided, they will take precedence in the specified order. Example-3: Parsing Unstructured Data. The viper package is fully equipped to read and extract information stored there. ReadConfig will read a configuration file, setting existing keys to nil if the One important thing to recognize when working with ENV variables is that the crypt has a command-line helper that you can use to put configurations in your When you explicitly provide the ENV variable name (the second parameter), You can This is a very simple example on how to implement this interface: Once your flag implements this interface, you can simply tell Viper to bind it: FlagValueSet represents a group of flags. Our config file is app.env, so its name is app. independently, together they make a powerful pair to handle much of your For example if the second parameter is "id", While both can operate completely // General information about what's happening inside the system. In today's post, we will walk through several scenarios to parse json files in Golang. // but exiting and panicing is out of scope for a logging library. 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). Currently only etcd and Consul are supported. the default value and the Get function would return: Unmarshal unmarshals the config into a Struct. // any approach to require this configuration into your program. // Non-critical events that should be looked at. How can I explain to my manager that a project he wishes to undertake cannot be performed by the team? niljsonnil . in golang, general function to load http form data into a struct. For example, an application might use multiple different cache stores for different purposes: We could pass the cache name to a module (eg. It returns nil if a key cannot be found. Many Go projects are built using Viper including: Note: Viper uses Go Modules to manage dependencies. This enables 12 factor reading from JSON, TOML, YAML, HCL, envfile and Java properties config files. 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, // contains filtered or unexported methods. . Get() calls, but want your environmental variables to use _ delimiters. Can Martian regolith be easily melted with microwaves? So instead of doing that let's pass a Viper instance to the constructor that represents a subset of the configuration: Note: Always check the return value of Sub. For example: Lastly, if there exists a key that matches the delimited key path, its value How Intuit democratizes AI development across teams through reusability. Find, load, and unmarshal a configuration file in JSON, TOML, YAML, HCL, INI, envfile or Java properties formats. prefix. You can also create many different vipers for use in your application. How to match a specific column position till the end of line? Will be used instead of values obtained via What video game is Charlie playing in Poker Face S01E07? variables that start with "SPF_". default values, but are overridden by configuration values retrieved from disk, config file, environment variable, remote configuration or flag. style approach. spf13/viper This was referenced Oct 26, 2020 This was referenced May 19, 2021 You can't perform that action at this time. A DecoderConfigOption can be passed to viper.Unmarshal to configure . package supports are mirrored as methods on a viper. A default value is not . Handling and updating configuration for a large and complex program, such as creating a server application or any other application that relies heavily on user configuration manipulation, is a difficult undertaking. Here is some quick example code of how to read a JSON configuration file in Go. In Viper, there are a few ways to get a value depending on the values type. where a configuration file is expected. FlagValue represents a single flag. etcd requires http://ip:port consul requires ip:port There are ongoing discussions about making that optional. Since, BindEnv can take more than one argument, each will represent environment variable names that bind to this key and will be taken in the specified order. datastore.metric.port are already defined (and may be overridden). the AllowEmptyEnv method. EnvPrefix will be used when set when env name is not provided. Marshal & Unmarshal in golang. It will Method-1: Use Viper package to read environment variable from file. UnmarshalKey takes a single key and unmarshals it into a Struct. configuration filetype. For example: Lastly, if there exists a key that matches the delimited key path, its value Are there tables of wastage rates for different fruit and veg? Golang has a concept of "exported" fields in struct datatypes and functions, so this essentially means that these exported fields are the ones which will be visible across different packages. one are provided, they will take precedence in the specified order. Minimising the environmental effects of my dyson brain. independently, together they make a powerful pair to handle much of your Error returns the formatted remote provider error. So instead of doing that let's pass a Viper instance to the constructor that represents a subset of the configuration: Note: Always check the return value of Sub. Aliases permit a single value to be referenced by multiple keys. The Unmarshal function doesn't create and return Go objects , so we have to pass a reference to store the decoded content. Viper uses the following precedence order. SetConfigPermissions sets the permissions for the config file. This is useful if you want to use - or something in your type Myconfig struct { Username string `mapstructure:"username"` } You can look at JSON and dealing with unexported . 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.