viper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvPrefixedName

func EnvPrefixedName(prefix, key string) string

EnvPrefixedName replicates the private viper.mergeWithEnvPrefix.

func IsSetInCommand

func IsSetInCommand(v *std_viper.Viper, c *cobra.Command, prefix, key string) bool

IsSetInCommand provides a viper.IsSet alternative that works around a bug which causes IsSet to always return true if the config key is bound to cobra: https://github.com/spf13/viper/issues/276.

The workaround logic doesn't support the case where a flag both has a default value and was also erroneously marked as required.

func MergeConfig

func MergeConfig(fs *pflag.FlagSet, v *std_viper.Viper) (lastErr error)

MergeConfig supplements the one-way binding provided by viper.BindPFlag(s) which only allows reading the bound config values via viper, e.g. GetString, but not through variables bound to configs by cobra, e.g. via StringVarP(). This allows reading of the bound values from the latter.

Author: https://github.com/spf13/viper/issues/35#issuecomment-71908327

Changes:

- Add stringSlice support.

func NewEnvSpace

func NewEnvSpace(prefix string) *std_viper.Viper

NewEnvSpace returns an initialized Viper instance configured to read all keys from an environment variable prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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