Documentation
¶
Index ¶
- func BindStruct(p Properties, v reflect.Value, opt BindOption) error
- func BindStructField(p Properties, v reflect.Value, str string, opt BindOption) error
- func BindValue(p Properties, v reflect.Value, key string, def interface{}, opt BindOption) error
- func New() *defaultProperties
- func Priority(curr Properties, next Properties) *priorityProperties
- func ResolveProperty(p Properties, _ string, value interface{}) (interface{}, error)
- func ToInt8SliceE(i interface{}) ([]int8, error)
- func ToInt16SliceE(i interface{}) ([]int16, error)
- func ToInt32SliceE(i interface{}) ([]int32, error)
- func ToInt64SliceE(i interface{}) ([]int64, error)
- func ToIntSliceE(i interface{}) ([]int, error)
- func ToUint8SliceE(i interface{}) ([]uint8, error)
- func ToUint16SliceE(i interface{}) ([]uint16, error)
- func ToUint32SliceE(i interface{}) ([]uint32, error)
- func ToUint64SliceE(i interface{}) ([]uint64, error)
- func ToUintSliceE(i interface{}) ([]uint, error)
- type BindOption
- type Converter
- type Properties
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindStruct ¶
func BindStruct(p Properties, v reflect.Value, opt BindOption) error
BindStruct 对结构体进行属性值绑定
func BindStructField ¶
func BindStructField(p Properties, v reflect.Value, str string, opt BindOption) error
BindStructField 对结构体的字段进行属性绑定
func BindValue ¶
func BindValue(p Properties, v reflect.Value, key string, def interface{}, opt BindOption) error
BindValue 对任意 value 进行属性绑定
func Priority ¶
func Priority(curr Properties, next Properties) *priorityProperties
Priority priorityProperties 的构造函数
func ResolveProperty ¶
func ResolveProperty(p Properties, _ string, value interface{}) (interface{}, error)
ResolveProperty 解析属性值,查看其是否具有引用关系
func ToInt8SliceE ¶
ToInt8SliceE casts an interface to a []int8 type.
func ToInt16SliceE ¶
ToInt16SliceE casts an interface to a []int16 type.
func ToInt32SliceE ¶
ToInt32SliceE casts an interface to a []int32 type.
func ToInt64SliceE ¶
ToInt64SliceE casts an interface to a []int64 type.
func ToIntSliceE ¶
ToIntSliceE casts an interface to a []int type.
func ToUint8SliceE ¶
ToUint8SliceE casts an interface to a []uint8 type.
func ToUint16SliceE ¶
ToUint16SliceE casts an interface to a []uint16 type.
func ToUint32SliceE ¶
ToUint32SliceE casts an interface to a []uint32 type.
func ToUint64SliceE ¶
ToUint64SliceE casts an interface to a []uint64 type.
func ToUintSliceE ¶
ToUintSliceE casts an interface to a []uint type.
Types ¶
type BindOption ¶
type BindOption struct {
PrefixName string // 属性名前缀
FullName string // 完整属性名
FieldName string // 结构体字段的名称
}
BindOption 属性值绑定可选项
type Properties ¶
type Properties interface {
// Load 加载属性配置,支持 properties、yaml 和 toml 三种文件格式。
Load(filename string) error
// Read 读取属性配置,支持 properties、yaml 和 toml 三种文件格式。
Read(reader io.Reader, configType string) error
// Convert 添加类型转换器
Convert(fn Converter) error
// Converters 返回类型转换器集合
Converters() map[reflect.Type]Converter
// Has 查询属性值是否存在,属性名称统一转成小写。
Has(key string) bool
// Bind 根据类型获取属性值,属性名称统一转成小写。
Bind(key string, i interface{}) error
// Get 返回属性值,不能存在返回 nil,属性名称统一转成小写。
Get(key string) interface{}
// GetFirst 返回 keys 中第一个存在的属性值,属性名称统一转成小写。
GetFirst(keys ...string) interface{}
// GetDefault 返回属性值,如果没有找到则使用指定的默认值,属性名称统一转成小写。
GetDefault(key string, def interface{}) interface{}
// Set 设置属性值,属性名称统一转成小写。
Set(key string, value interface{})
// Keys 返回所有键,属性名称统一转成小写。
Keys() []string
// Range 遍历所有的属性值,属性名称统一转成小写。
Range(fn func(string, interface{}))
// Fill 填充所有的属性值,属性名称统一转成小写。
Fill(properties map[string]interface{})
// Prefix 返回指定前缀的属性值集合,属性名称统一转成小写。
Prefix(key string) map[string]interface{}
// Group 返回指定前缀的属性值集合并进行分组,属性名称统一转成小写。
Group(key string) map[string]map[string]interface{}
}
Properties 定义属性值接口