viper

package
v0.79.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package viper provides convenience functions over the official spf13/viper library. In particular, it satisfies the need of providing a custom pre-configured global viper instance.

Index

Constants

This section is empty.

Variables

Default is the default, pre-configured instance of viper.

Functions

func AddConfigPath

func AddConfigPath(in string)

AddConfigPath adds a path for Viper to search for the config file in. Can be called multiple times to define multiple search paths.

func BindPFlag

func BindPFlag(key string, flag *pflag.Flag) error

BindPFlag binds a specific key to a pflag (as used by cobra). Example (where serverCmd is a Cobra instance):

serverCmd.Flags().Int("port", 1138, "Port to run Application server on")
Viper.BindPFlag("port", serverCmd.Flags().Lookup("port"))

func ReadInConfig

func ReadInConfig() error

ReadInConfig will discover and load the configuration file from disk and key/value stores, searching in one of the defined paths.

func Set

func Set(key string, value interface{})

Set sets the value for the key in the override register. Set is case-insensitive for a key. Will be used instead of values obtained via flags, config file, ENV, default, or key/value store.

func SetConfigName

func SetConfigName(in string)

SetConfigName sets name for the config file. Does not include extension.

func Unmarshal

func Unmarshal(rawVal interface{}, opts ...viper.DecoderConfigOption) error

Unmarshal unmarshals the config into a Struct. Make sure that the tags on the fields of the structure are properly set.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL