Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.27.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipDatabaseConfig bool

Functions

func SetCfgSecKeyGetter

func SetCfgSecKeyGetter(p CfgSecKeyGetter)

func SetDynGetter

func SetDynGetter(p DynKeyGetter)

Types

type CfgSecKey

type CfgSecKey struct {
	Sec, Key string
}

type CfgSecKeyGetter

type CfgSecKeyGetter interface {
	GetValue(sec, key string) (v string, has bool)
}

func GetCfgSecKeyGetter

func GetCfgSecKeyGetter() CfgSecKeyGetter

type DynKeyGetter

type DynKeyGetter interface {
	GetValue(ctx context.Context, key string) (v string, has bool)
	GetRevision(ctx context.Context) int
	InvalidateCache()
}

func GetDynGetter

func GetDynGetter() DynKeyGetter

type Option

type Option[T any] struct {
	// contains filtered or unexported fields
}

func NewOption

func NewOption[T any](dynKey string) *Option[T]

func (*Option[T]) DefaultValue

func (opt *Option[T]) DefaultValue() T

func (*Option[T]) DynKey

func (opt *Option[T]) DynKey() string

func (*Option[T]) GetDefaultValue

func (opt *Option[T]) GetDefaultValue() any

func (*Option[T]) HasValue

func (opt *Option[T]) HasValue(ctx context.Context) bool

func (*Option[T]) Value

func (opt *Option[T]) Value(ctx context.Context) (v T)

func (*Option[T]) ValueRevision

func (opt *Option[T]) ValueRevision(ctx context.Context) (v T, rev int, has bool)

func (*Option[T]) WithDefaultFunc

func (opt *Option[T]) WithDefaultFunc(f func() T) *Option[T]

WithDefaultFunc sets the default value with a function The "def" value might be changed during runtime (e.g.: Unmarshal with default), so it shouldn't use the same pointer or slice

func (*Option[T]) WithDefaultSimple

func (opt *Option[T]) WithDefaultSimple(def T) *Option[T]

func (*Option[T]) WithEmptyAsDefault

func (opt *Option[T]) WithEmptyAsDefault() *Option[T]

func (*Option[T]) WithFileConfig

func (opt *Option[T]) WithFileConfig(cfgSecKey CfgSecKey) *Option[T]

type OptionInterface

type OptionInterface interface {
	GetDefaultValue() any
}

OptionInterface is used to overcome Golang's generic interface limitation

func GetConfigOption

func GetConfigOption(dynKey string) OptionInterface

Jump to

Keyboard shortcuts

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