config

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config 提供了对多种格式配置文件的支持

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager added in v0.18.0

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

Manager 对 UnmarshalFunc 与扩展名的关联管理。

func NewManager added in v0.18.0

func NewManager(dir string) (*Manager, error)

NewManager 新的 Manager 实例

func (*Manager) AddUnmarshal added in v0.18.0

func (mgr *Manager) AddUnmarshal(m UnmarshalFunc, ext ...string) error

AddUnmarshal 注册解析函数

func (*Manager) File added in v0.18.0

func (mgr *Manager) File(path string) string

File 获取文件路径,相对于当前配置目录

func (*Manager) Load added in v0.18.0

func (mgr *Manager) Load(r io.Reader, typ string, v interface{}) error

Load 加载指定的配置文件内容到 v 中

func (*Manager) LoadFile added in v0.18.0

func (mgr *Manager) LoadFile(path string, v interface{}) error

LoadFile 加载指定的配置文件内容到 v 中

func (*Manager) SetUnmarshal added in v0.18.0

func (mgr *Manager) SetUnmarshal(m UnmarshalFunc, ext ...string) error

SetUnmarshal 修改指定扩展名关联的解析函数,不存在则添加。

type Sanitizer

type Sanitizer interface {
	Sanitize() error
}

Sanitizer 如果对象实现了该方法,那么在解析完之后, 会调用该接口的函数对数据进行修正和检测。

type UnmarshalFunc

type UnmarshalFunc func([]byte, interface{}) error

UnmarshalFunc 定义了将文本内容解析到对象的函数原型。

Jump to

Keyboard shortcuts

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