conf

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Template   string
	WriteTo    string
	DefaultVal interface{}
	// contains filtered or unexported fields
}
var (
	GlobalViper *Config
)

func New

func New(opts ...Option) *Config

func (*Config) Get

func (c *Config) Get(key string) interface{}

func (*Config) GetBool

func (c *Config) GetBool(key string) bool

func (*Config) GetDuration

func (c *Config) GetDuration(key string) time.Duration

func (*Config) GetFloat64

func (c *Config) GetFloat64(key string) float64

func (*Config) GetInt

func (c *Config) GetInt(key string) int

func (*Config) GetInt32

func (c *Config) GetInt32(key string) int32

func (*Config) GetInt64

func (c *Config) GetInt64(key string) int64

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(key string) []int

func (*Config) GetMapSlice

func (c *Config) GetMapSlice(key string) []map[string]interface{}

func (*Config) GetString

func (c *Config) GetString(key string) string

func (*Config) GetStringMap

func (c *Config) GetStringMap(key string) map[string]interface{}

func (*Config) GetStringMapString

func (c *Config) GetStringMapString(key string) map[string]string

func (*Config) GetStringMapStringSlice

func (c *Config) GetStringMapStringSlice(key string) map[string][]string

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(key string) []string

func (*Config) GetTime

func (c *Config) GetTime(key string) time.Time

func (*Config) GetUint

func (c *Config) GetUint(key string) uint

func (*Config) GetUint16

func (c *Config) GetUint16(key string) uint16

func (*Config) GetUint32

func (c *Config) GetUint32(key string) uint32

func (*Config) GetUint64

func (c *Config) GetUint64(key string) uint64

func (*Config) Read

func (c *Config) Read() error

Read is used to parsing conf. when conf does not exist, func will try to write into conf file from template parsing with default value.

func (*Config) Write

func (c *Config) Write() error

Write is used in cli for generate conf file with conf template which may contains description message for each section and option.

type Option

type Option func(c *Config)

func WithAllowEmptyEnv

func WithAllowEmptyEnv() Option

func WithAutomaticEnv

func WithAutomaticEnv() Option

func WithBindEnv

func WithBindEnv(envs map[string]string) Option

func WithConfigName

func WithConfigName(in string) Option

func WithConfigType

func WithConfigType(in string) Option

func WithDefaultVal

func WithDefaultVal(i interface{}) Option

WithDefaultVal is used to set the conf struct unmarshalling to

func WithEnvKeyReplacer

func WithEnvKeyReplacer(r *strings.Replacer) Option

func WithFsNotify

func WithFsNotify() Option

func WithOptionConfigPath

func WithOptionConfigPath(path []string) Option

func WithTemplate

func WithTemplate(template string) Option

func WithWriteTo

func WithWriteTo(path string) Option

func WriteTemplateFromFile

func WriteTemplateFromFile(path string) Option

Jump to

Keyboard shortcuts

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