pflags

package
v1.1.24 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStruct = errors.New("not struct")
)

Functions

func BindPFlag

func BindPFlag(key string, flag *pflag.Flag)

func Duration

func Duration(key string, defaultValue time.Duration, usage string) func() time.Duration

func DurationRequired

func DurationRequired(key, usage string) func() time.Duration

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)

func Struct

func Struct(key string, defaultVal any, usage string) func(out any) error

func Viper

func Viper() *viper.Viper

Types

type BoolGetter

type BoolGetter func() bool

func Bool

func Bool(key string, defaultVal bool, usage string) BoolGetter

func BoolRequired

func BoolRequired(key, usage string) BoolGetter

func (BoolGetter) Value

func (bg BoolGetter) Value() bool

type Float64Getter

type Float64Getter func() float64

func Float64

func Float64(key string, defaultVal float64, usage string) Float64Getter

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 IntGetter

type IntGetter func() int

func Int

func Int(key string, defaultVal int, usage string) IntGetter

func IntRequired

func IntRequired(key, usage string) IntGetter

func (IntGetter) Value

func (ig IntGetter) Value() int

type Option

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

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

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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