Documentation
¶
Index ¶
- func CamelToSnake(s string) string
- func SnakeToCamel(s string) string
- func ToMap(input interface{}) (map[string]interface{}, error)
- func ToStruct(input map[string]interface{}, output interface{}) error
- func Transform(input, output interface{}) error
- type Converter
- func (c *Converter) Convert(input, output interface{}) error
- func (c *Converter) ConvertSlice(inputSlice interface{}, outputSlice interface{}) error
- func (c *Converter) MapToStruct(input map[string]interface{}, output interface{}) error
- func (c *Converter) MustConvert(input, output interface{})
- func (c *Converter) StructToMap(input interface{}) (map[string]interface{}, error)
- func (c *Converter) WithDecodeHook(hook mapstructure.DecodeHookFunc) *Converter
- func (c *Converter) WithTagName(tagName string) *Converter
- func (c *Converter) WithWeaklyTyped(enable bool) *Converter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Converter ¶
type Converter struct {
// contains filtered or unexported fields
}
Converter 结构体转换器
func (*Converter) ConvertSlice ¶
ConvertSlice 转换切片
func (*Converter) MapToStruct ¶
MapToStruct 将 map 转换为结构体
func (*Converter) MustConvert ¶
func (c *Converter) MustConvert(input, output interface{})
MustConvert 安全转换,如果出错会 panic
func (*Converter) StructToMap ¶
StructToMap 将结构体转换为 map(支持嵌套结构体)
func (*Converter) WithDecodeHook ¶
func (c *Converter) WithDecodeHook(hook mapstructure.DecodeHookFunc) *Converter
WithDecodeHook 添加自定义解码钩子
func (*Converter) WithTagName ¶
WithTagName 设置自定义标签名
func (*Converter) WithWeaklyTyped ¶
WithWeaklyTyped 设置弱类型转换
Click to show internal directories.
Click to hide internal directories.