viperutil

package
v0.0.0-...-579b097 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPaths

func ConfigPaths() []string

ConfigPaths returns the paths from environment and defaults which are CWD and /etc/hyperledger/fabric.

func YamlStringToStructHook

func YamlStringToStructHook(m interface{}) func(rf reflect.Kind, rt reflect.Kind, data interface{}) (interface{}, error)

YamlStringToStructHook is a hook for viper(viper.Unmarshal(*,*, here)), it is able to parse a string of minified yaml into a slice of structs

Types

type ConfigParser

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

ConfigParser holds the configuration file locations. It keeps the config file directory locations and env variables. From the file the config is unmarshalled and stored. Currently "yaml" is supported.

func New

func New() *ConfigParser

New creates a ConfigParser instance

func (*ConfigParser) AddConfigPaths

func (c *ConfigParser) AddConfigPaths(cfgPaths ...string)

AddConfigPaths keeps a list of path to search the relevant config file. Multiple paths can be provided.

func (*ConfigParser) ConfigFileUsed

func (c *ConfigParser) ConfigFileUsed() string

ConfigFileUsed returns the used configFile.

func (*ConfigParser) EnhancedExactUnmarshal

func (c *ConfigParser) EnhancedExactUnmarshal(output interface{}) error

EnhancedExactUnmarshal is intended to unmarshal a config file into a structure producing error when extraneous variables are introduced and supporting the time.Duration type

func (*ConfigParser) ReadConfig

func (c *ConfigParser) ReadConfig(in io.Reader) error

ReadConfig parses the buffer and initializes the config.

func (*ConfigParser) ReadInConfig

func (c *ConfigParser) ReadInConfig() error

ReadInConfig reads and unmarshals the config file.

func (*ConfigParser) SetConfigName

func (c *ConfigParser) SetConfigName(in string)

SetConfigName provides the configuration file name stem. The upper-cased version of this value also serves as the environment variable override prefix.

Jump to

Keyboard shortcuts

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