config

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	OptionName = "name"
	OptionDesc = "description"
)
View Source
const (
	LogDefault = "default"
)

Variables

View Source
var (
	DefaultLogLevel = logger.LOG_LEVEL_INFO
	LogLevel        = DefaultLogLevel
	LogColor        = true
	Verbose         bool
)
View Source
var (
	Flag          *flag.FlagSet = flag.NewFlagSet("", flag.ContinueOnError)
	ErrNonPointer               = errors.New("validate with non-pointer")
	ErrPrintUsage               = errors.New("print usage")
)

Functions

func GetDefaultLogger

func GetDefaultLogger() logger.Logger

func GetLogger

func GetLogger(prefix string) logger.Logger

func InitLogger

func InitLogger(log *logger.Logger, prefix interface{})

func Polyfill

func Polyfill(opts Options, fill Options) error

func ValidateOptions

func ValidateOptions(opts Options) (*flag.FlagSet, error)

ValidateOptions validates the options with command line arguments. Returns a FlagSet and error. If returns ErrPrintUsage, the usage should be printed.

func ValidateOptionsWithFlags

func ValidateOptionsWithFlags(opts Options, args ...string) (*flag.FlagSet, error)

ValidateOptionsWithFlags validates the options with specified arguments. Returns a FlagSet and error. If returns ErrPrintUsage, the usage should be printed.

Types

type LoggerOptions

type LoggerOptions struct {
	Options

	Debug   bool `name:"debug" description:"Display debug logs."`
	Verbose bool `name:"v" description:"Display verbose logs."`
}

func (*LoggerOptions) Validate

func (o *LoggerOptions) Validate() error

type Options

type Options interface {
	// Validate validates the options.
	Validate() error
	// contains filtered or unexported methods
}

Options is the interface for all config options. See the package-level substructs to define your options.

func NewOptions

func NewOptions() Options

type SeedOptions

type SeedOptions struct {
	Options

	Seed int64 `name:"seed" description:"Random seed to reproduce simulation."`
}

func (*SeedOptions) Validate

func (opts *SeedOptions) Validate() error

Jump to

Keyboard shortcuts

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