builder

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ViperBuilder

type ViperBuilder struct {
	// contains filtered or unexported fields
}

ViperBuilder is a builder to streamline Viper configuration and building.

func New

func New(name string) *ViperBuilder

New initializes and returns a new ViperBuilder.

func (*ViperBuilder) Build

func (vb *ViperBuilder) Build() (*viper.Viper, error)

Build builds the Viper config and returns it. It first extracts a Viper instance for the specific environment it's running in, then explicitly calls BindEnv for each of the attributes of the configuration. This is done to force Viper to be aware of the ENV variables for each of those configuration attributes. The Viper instance returned by this function can be unmarshalled by the caller in a configuration-specific type while respecting the precedence order.

func (*ViperBuilder) ConfigPath

func (vb *ViperBuilder) ConfigPath(path string) *ViperBuilder

ConfigPath sets the path argument as the Viper config path.

func (*ViperBuilder) SetDefault

func (vb *ViperBuilder) SetDefault(key string, value interface{}) *ViperBuilder

SetDefault sets a default value for a configuration key. Any default value set will be available in the `viper.Viper` configuration instance that is returned after calling the `Build()` function.

Jump to

Keyboard shortcuts

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