viper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 6 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustInit

func MustInit(envPrefix string)

MustInit inits viper with provided env var prefix.

Note that it will panic and exit if any error happens.

func MustUnmarshalKey

func MustUnmarshalKey(key string, valPtr interface{}, resolver ...ValueResolver)

MustUnmarshalKey unmarshal setting to value pointer by key from viper.

Note that it will panic and exit if failed to unmarshal value from key.

func UnmarshalKey

func UnmarshalKey(key string, valPtr interface{}, resolver ...ValueResolver) error

UnmarshalKey unmarshal setting to value pointer by key from viper.

Provide custom value resolver if unmarshalling some special types like slice. Note that valPtr must be some value pointer and not be nil.

Types

type ValueResolver

type ValueResolver func(key string) (interface{}, bool)

ValueResolver defines custom method to get value by key from viper settings.

Jump to

Keyboard shortcuts

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