Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WeaklyIgnoreSeperator is used to ignore the seperator in the tag name. WeaklyIgnoreSeperator = true // WeaklyDashUnderscore is used to convert dash to underscore in the tag name. // If WeaklyIgnoreSeperator is set to true then this will be ignored. WeaklyDashUnderscore = false // HooksDecode functions to convert value before decoding. HooksDecode = []struct2.HookDecodeFunc{ func(t1, t2 reflect.Type, data interface{}) (interface{}, error) { if t2 != reflect.TypeOf(time.Duration(0)) { return data, nil } switch t1.Kind() { case reflect.String: return str2duration.ParseDuration(data.(string)) case reflect.Int: return time.Duration(data.(int)), nil case reflect.Int64: return time.Duration(data.(int64)), nil case reflect.Float64: return time.Duration(data.(float64)), nil default: return data, nil } }, } )
View Source
var BackupTagName = "cfg"
BackupTagName is the tag name used if tagname not found in the struct tags.
Functions ¶
func LoadReaderWithDecoder ¶
LoadReaderWithDecoder will decode input in `r` into `to` by using `decoder`.
func MapDecoder ¶
MapDecoder implements the reformat package, it exposes functionality to convert an arbitrary map[string]interface{} into a native Go structure with given tag name.
Types ¶
type Decoder ¶
Decoder is a interface that will decode reader `r` into `to`.
`to` will already be pointer to struct, so no need to further prepare it for decoding.
Click to show internal directories.
Click to hide internal directories.