configloader

package
Version: v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultExt = "json"

Variables

View Source
var Extensions = make(map[string]LoaderFunction)

Functions

func Load

func Load(ext string, data []byte, v interface{}) error

指定扩展名和数据,加载配置

func LoadFile

func LoadFile(file string, v interface{}) error

加载指定文件的配置 如果文件名为 .* 结尾,则表示依次尝试加载支持的文件扩展名

func LoadFromReader

func LoadFromReader(ext string, reader io.Reader, v interface{}) error

指定扩展名和Reader,加载配置

func MustLoadFile

func MustLoadFile(file string, v interface{})

加载指定文件的配置,如果出错则panic

func RegisterExtensionHandler

func RegisterExtensionHandler(ext string, loader LoaderFunction)

注册文件扩展名对应的解析器

Types

type LoaderFunction

type LoaderFunction = func(data []byte, v interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL