config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 7 Imported by: 0

README

设置默认值 从JSON、TOML、YAML、HCL、envfile和Java properties格式的配置文件读取配置信息 实时监控和重新读取配置文件(可选) 从环境变量中读取 从远程配置系统(etcd或Consul)读取并监控配置变化 从命令行参数读取配置 从buffer读取配置 显式配置值

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	Load() error
	Scan(v any) error
	Source() ([]byte, error)
}

Config is a config interface.

func New

func New(opts ...Option) Config

New a config with options.

type Decoder

type Decoder func(*KeyValue, map[string]any) error

Decoder is config decoder.

type KeyValue

type KeyValue struct {
	Key    string
	Value  []byte
	Format string
}

KeyValue is config key value.

type Option

type Option func(*options)

Option is config option.

func WithDecoder

func WithDecoder(d Decoder) Option

func WithSource

func WithSource(s ...Source) Option

WithSource with config source.

type Source

type Source interface {
	Load() ([]*KeyValue, error)
}

Source is config source.

type Value

type Value interface {
	Bool() (bool, error)
	Int() (int, error)
	Float() (float32, error)
	String() (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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