Documentation
¶
Index ¶
- Variables
- func BindPFlag(key string, flag *pflag.Flag)
- func Duration(key string, defaultValue time.Duration, usage string) func() time.Duration
- func DurationRequired(key, usage string) func() time.Duration
- func GetServiceName() string
- func OverrideDefaultConfigFile(configFile string)
- func Parse(opts ...OptionFunc)
- func SetDefaultConfigReader(reader reader.ConfigReader)
- func SetDefaultConfigWatcher(watchers watcher.ConfigWatcher)
- func SetStructParseTagName(t string)
- func Struct(key string, defaultVal any, usage string) func(out any) error
- func Viper() *viper.Viper
- type BoolGetter
- type Float64Getter
- type HasDefault
- type HasReloader
- type HasValidator
- type IntGetter
- type Option
- type OptionFunc
- type StringGetter
- type StringSliceGetter
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNotStruct = errors.New("not struct")
)
Functions ¶
func DurationRequired ¶
func GetServiceName ¶
func GetServiceName() string
func OverrideDefaultConfigFile ¶
func OverrideDefaultConfigFile(configFile string)
func Parse ¶
func Parse(opts ...OptionFunc)
func SetDefaultConfigReader ¶ added in v1.1.7
func SetDefaultConfigReader(reader reader.ConfigReader)
func SetDefaultConfigWatcher ¶ added in v1.1.7
func SetDefaultConfigWatcher(watchers watcher.ConfigWatcher)
func SetStructParseTagName ¶ added in v1.0.1
func SetStructParseTagName(t string)
Types ¶
type BoolGetter ¶
type BoolGetter func() bool
func BoolRequired ¶
func BoolRequired(key, usage string) BoolGetter
func (BoolGetter) Value ¶
func (bg BoolGetter) Value() bool
type Float64Getter ¶
type Float64Getter func() float64
func Float64Required ¶
func Float64Required(key, usage string) Float64Getter
func (Float64Getter) Value ¶
func (fg Float64Getter) Value() float64
type HasDefault ¶
type HasDefault interface {
SetDefault()
}
type HasReloader ¶
type HasReloader interface {
Reload()
}
type HasValidator ¶
type HasValidator interface {
Validate() error
}
type OptionFunc ¶
type OptionFunc func(*Option)
func WithConfigFileName ¶ added in v1.1.24
func WithConfigFileName(n string) OptionFunc
func WithConfigFileType ¶ added in v1.1.24
func WithConfigFileType(t string) OptionFunc
func WithConfigReader ¶
func WithConfigReader(reader reader.ConfigReader) OptionFunc
func WithConfigWatcher ¶
func WithConfigWatcher(watchers ...watcher.ConfigWatcher) OptionFunc
type StringGetter ¶
type StringGetter func() string
func String ¶
func String(key, defaultVal, usage string) StringGetter
func StringP ¶
func StringP(key, shorthand, defaultVal, usage string) StringGetter
func StringRequired ¶
func StringRequired(key, usage string) StringGetter
func (StringGetter) Value ¶
func (sg StringGetter) Value() string
type StringSliceGetter ¶
type StringSliceGetter func() []string
func StringSlice ¶
func StringSlice(key string, defaultVal []string, usage string) StringSliceGetter
func (StringSliceGetter) Value ¶
func (sg StringSliceGetter) Value() []string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.