config

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func New

func New(opts ...Option) (*Config, error)

func (*Config) Delete

func (c *Config) Delete(key string)

func (*Config) Mandatory

func (c *Config) Mandatory() Mandatory

func (*Config) Optional

func (c *Config) Optional() Optional

func (*Config) Read

func (c *Config) Read(ptr any) error

func (*Config) Set

func (c *Config) Set(key string, value any)

type Mandatory

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

func (Mandatory) Bool

func (m Mandatory) Bool(key string) (bool, error)

func (Mandatory) Duration

func (m Mandatory) Duration(key string) (time.Duration, error)

func (Mandatory) Int

func (m Mandatory) Int(key string) (int, error)

func (Mandatory) String

func (m Mandatory) String(key string) (string, error)

type Option

type Option func(l *Config)

func WithEnvPrefix

func WithEnvPrefix(prefix string) Option

func WithExtraSource

func WithExtraSource(source Source) Option

func WithValidator

func WithValidator(validator Validator) Option

type Optional

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

func (Optional) Bool

func (o Optional) Bool(key string, defValue bool) bool

func (Optional) Duration

func (o Optional) Duration(key string, defValue time.Duration) time.Duration

func (Optional) Int

func (o Optional) Int(key string, defValue int) int

func (Optional) String

func (o Optional) String(key string, defValue string) string

type Source

type Source interface {
	Config() (map[string]string, error)
}

type Validator

type Validator interface {
	ValidateToError(value any) error
}

type YamlFileSource

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

func NewYamlConfig

func NewYamlConfig(file string) YamlFileSource

func (YamlFileSource) Config

func (y YamlFileSource) Config() (map[string]string, error)

Jump to

Keyboard shortcuts

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