config

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 14 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() map[string]any

func Args added in v1.1.1

func Args() []string

func Expand

func Expand(s string) string

func ForEach

func ForEach(path string, fn func(c *Config) error) error

func GetBool

func GetBool(path string) bool

func GetDuration

func GetDuration(path string) time.Duration

func GetFloat64

func GetFloat64(path string) float64

func GetFloat64Slice

func GetFloat64Slice(path string) []float64

func GetInt

func GetInt(path string) int

func GetInt64

func GetInt64(path string) int64

func GetInt64Slice

func GetInt64Slice(path string) []int64

func GetIntSlice

func GetIntSlice(path string) []int

func GetInterface

func GetInterface(path string) any

func GetString

func GetString(path string) string

func GetStringMap

func GetStringMap(path string) map[string]string

func GetStringSlice

func GetStringSlice(path string) []string

func GetTime

func GetTime(path string) time.Time

func GetUint

func GetUint(path string) uint

func GetUint64

func GetUint64(path string) uint64

func GetUint64Slice

func GetUint64Slice(path string) []uint64

func GetUintSlice

func GetUintSlice(path string) []uint

func Has added in v1.1.1

func Has(path string) bool

func ParseTime

func ParseTime(v string) (time.Time, error)

func ReadConfigFile

func ReadConfigFile(name string, failNonExist bool) error

func Unmarshal

func Unmarshal(path string, val any) error

Types

type Config

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

func Branch added in v1.1.1

func Branch(path string) (*Config, error)

func NewConfig

func NewConfig() *Config

func Set

func Set(key string, val any) *Config

func SetDefault

func SetDefault(key string, val any) *Config

func SetEnvPrefix

func SetEnvPrefix(p string) *Config

func UseEnv

func UseEnv(enabled bool) *Config

func (*Config) All

func (c *Config) All() map[string]any

func (*Config) Args added in v1.1.1

func (c *Config) Args() []string

func (*Config) Branch added in v1.1.1

func (c *Config) Branch(path string) (*Config, error)

func (*Config) EnvPrefix

func (c *Config) EnvPrefix() string

func (*Config) Expand

func (c *Config) Expand(s string) string

Resolves env/config variables embedded in a string using ${VAR}

func (*Config) ForEach

func (c *Config) ForEach(path string, fn func(c *Config) error) error

func (*Config) GetBool

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

func (*Config) GetDuration

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

func (*Config) GetFloat64

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

func (*Config) GetFloat64Slice

func (c *Config) GetFloat64Slice(path string) []float64

func (*Config) GetInt

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

func (*Config) GetInt64

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

func (*Config) GetInt64Slice

func (c *Config) GetInt64Slice(path string) []int64

func (*Config) GetIntSlice

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

func (*Config) GetInterface

func (c *Config) GetInterface(path string) any

func (*Config) GetString

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

func (*Config) GetStringMap

func (c *Config) GetStringMap(path string) map[string]string

func (*Config) GetStringSlice

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

func (*Config) GetTime

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

func (*Config) GetUint

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

func (*Config) GetUint64

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

func (*Config) GetUint64Slice

func (c *Config) GetUint64Slice(path string) []uint64

func (*Config) GetUintSlice

func (c *Config) GetUintSlice(path string) []uint

func (*Config) Has added in v1.1.1

func (c *Config) Has(path string) bool

func (*Config) ReadConfigFile

func (c *Config) ReadConfigFile(name string, failNonExist ...bool) error

func (*Config) ReadJSON added in v1.2.0

func (c *Config) ReadJSON(buf []byte) error

func (*Config) ReadYAML added in v1.2.0

func (c *Config) ReadYAML(buf []byte) error

func (*Config) Reapply added in v1.1.3

func (c *Config) Reapply()

func (*Config) Set

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

func (*Config) SetDefault

func (c *Config) SetDefault(key string, val any) *Config

func (*Config) SetEnvPrefix

func (c *Config) SetEnvPrefix(p string) *Config

func (*Config) Unmarshal

func (c *Config) Unmarshal(path string, val any) error

func (*Config) Use

func (c *Config) Use(val map[string]any) *Config

func (*Config) UseEnv

func (c *Config) UseEnv(enabled bool) *Config

type Duration

type Duration time.Duration

func ParseDuration

func ParseDuration(d string) (Duration, error)

func (Duration) Duration

func (d Duration) Duration() time.Duration

type Stringer added in v1.2.0

type Stringer interface {
	String() string
}

Jump to

Keyboard shortcuts

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