Documentation
¶
Index ¶
- Constants
- Variables
- func CheckInIsNil(in interface{}) bool
- func GetFieldNameByTag(field reflect.StructField, tag string) string
- func Indirect(a interface{}) interface{}
- func ReflectTypeValue(source interface{}) (reflect.Type, reflect.Value)
- func ToAny(in interface{}, out interface{}, options ...Options) error
- func ToBool(v interface{}) bool
- func ToBoolE(v interface{}, op ...Options) (bool, error)
- func ToFloat32(v interface{}) float32
- func ToFloat64(v interface{}) float64
- func ToFloat64E(v interface{}, op ...Options) (float64, error)
- func ToInt(v interface{}) int
- func ToInt8(v interface{}) int8
- func ToInt16(v interface{}) int16
- func ToInt32(v interface{}) int32
- func ToInt64(v interface{}) int64
- func ToInt64E(v interface{}, op ...Options) (int64, error)
- func ToString(v interface{}) string
- func ToStringE(v interface{}, op ...Options) (string, error)
- func ToTime(v interface{}, op ...Options) time.Time
- func ToTimeE(v interface{}, op ...Options) (time.Time, error)
- func ToUint(v interface{}) uint
- func ToUint8(v interface{}) uint8
- func ToUint16(v interface{}) uint16
- func ToUint32(v interface{}) uint32
- func ToUint64(v interface{}) uint64
- func ToUint64E(v interface{}, op ...Options) (uint64, error)
- type HookFunc
- type IAny
- type Options
- func (op *Options) AddHook(v HookFunc) *Options
- func (op *Options) SetAssignKey(v map[string]string) *Options
- func (op *Options) SetExportedUnExported(v bool) *Options
- func (op *Options) SetLocation(v *time.Location) *Options
- func (op *Options) SetMapKeyField(v string) *Options
- func (op *Options) SetMapKeyToList(v bool) *Options
- func (op *Options) SetStructToMapDetail(v bool) *Options
- func (op *Options) SetTagName(v string) *Options
- func (op *Options) SetTimeFormat(v string) *Options
Constants ¶
const ( DecodeContinue = iota // continue with decoding as normal DecodeSkip // skip decoding of the field DecodeStop // stop decoding )
const (
TagIgnore = "-"
)
Variables ¶
var ( ErrDecodeStop = errors.New("decode stop") ErrBasic = "unable to convert %#v(type %[1]T) to " ErrInToOut = "unable to convert %#v(type %[1]T) to %s" ErrFieldNoFound = "the specified field was not found key: %s" ErrUnSupportType = "unsupported out type %v" ErrUnableConvertBasic = ErrBasic + "basic type" ErrUnableConvertInt64 = ErrBasic + "int64" ErrUnableConvertUint64 = ErrBasic + "uint64" ErrUnableConvertFloat64 = ErrBasic + "float64" ErrUnableConvertString = ErrBasic + "string" ErrUnableConvertBool = ErrBasic + "bool" ErrUnableConvertTime = ErrBasic + "time" ErrNotJson = "the input %#v(type %[1]T) is not json, or not map or slice" ErrInNotPtr = errors.New("if want to export a unexported field, the input must be of pointer type") )
Functions ¶
func GetFieldNameByTag ¶
func GetFieldNameByTag(field reflect.StructField, tag string) string
GetFieldNameByTag returns the field name by tag. if tag is gorm, get column name if tag name is nil, get field name
func Indirect ¶
func Indirect(a interface{}) interface{}
The Indirect function dereferences an interface{} value until it reaches a non-pointer base value or a nil value.
func ReflectTypeValue ¶
ReflectTypeValue returns the reflect.Type and reflect.Value of source.
func ToAny ¶
ToAny converts an interface to an any type. It uses reflection to dynamically decode the input value into the output container based on the output's type.
func ToFloat32 ¶
func ToFloat32(v interface{}) float32
ToFloat32 convert an interface to a float32 type
func ToFloat64 ¶
func ToFloat64(v interface{}) float64
ToFloat64 convert an interface to a float64 type
func ToFloat64E ¶
Types ¶
type HookFunc ¶
some field can customize the parsing, such as time.Duration, net.IP, net.IPNet. return DecodeStop if the hook has handled the decoding of the field.
type IAny ¶
type IAny interface {
// contains filtered or unexported methods
}
IAny defines an interface for converting various types to the 'any' type.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is a struct for specifying configuration options for any client.
func NewOptions ¶
func NewOptions() *Options
NewOptions creates a new options. The default options are: