config

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnSupportedConfigExtension = errors.New("unsupported config extension")
	ErrConfigFilePathIsDir        = errors.New("config file path is a directory")
	ErrConfigContentNotExists     = errors.New("config content not exists")
)

Functions

func LoadConfig

func LoadConfig(receiver any, path string) (err error)

LoadConfig 从指定路径加载配置到 receiver 中,通过文件扩展名自动识别配置文件类型,支持 yaml、json、xml

func LoadConfigWithKeys

func LoadConfigWithKeys(receiver any, path string, keys ...string) (err error)

LoadConfigWithKeys 从指定路径加载配置到 receiver 中,只加载指定的配置项,通过文件扩展名自动识别配置文件类型,支持 yaml、json

func LoadEmbedConfig added in v1.2.15

func LoadEmbedConfig(receiver any, fs embed.FS, name string) (err error)

func LoadEmbedConfigWithKeys added in v1.2.15

func LoadEmbedConfigWithKeys(receiver any, fs embed.FS, name string, keys ...string) (err error)

func WriteConfig added in v1.2.15

func WriteConfig(path string, object any) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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