Fixed incompatible type error handling
This commit is contained in:
parent
26d353867b
commit
0d6b55960b
24
unmarshal.go
24
unmarshal.go
|
@ -118,84 +118,84 @@ func init() {
|
|||
RegisterDecoder("bool", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*bool); ok {
|
||||
*i, n, err = UnmarshalBool(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected bool")
|
||||
})
|
||||
RegisterDecoder("int8", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*int8); ok {
|
||||
*i, n, err = UnmarshalInt8(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected int8")
|
||||
})
|
||||
RegisterDecoder("uint8", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*uint8); ok {
|
||||
*i, n, err = UnmarshalUint8(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected uint8")
|
||||
})
|
||||
RegisterDecoder("int16", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*int16); ok {
|
||||
*i, n, err = UnmarshalInt16(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected int16")
|
||||
})
|
||||
RegisterDecoder("uint16", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*uint16); ok {
|
||||
*i, n, err = UnmarshalUint16(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected uint16")
|
||||
})
|
||||
RegisterDecoder("int32", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*int32); ok {
|
||||
*i, n, err = UnmarshalInt32(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected int32")
|
||||
})
|
||||
RegisterDecoder("uint32", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*uint32); ok {
|
||||
*i, n, err = UnmarshalUint32(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected uint32")
|
||||
})
|
||||
RegisterDecoder("float32", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*float32); ok {
|
||||
*i, n, err = UnmarshalFloat32(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected float32")
|
||||
})
|
||||
RegisterDecoder("int64", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*int64); ok {
|
||||
*i, n, err = UnmarshalInt64(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected int64")
|
||||
})
|
||||
RegisterDecoder("uint64", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*uint64); ok {
|
||||
*i, n, err = UnmarshalUint64(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected uint64")
|
||||
})
|
||||
RegisterDecoder("float64", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*float64); ok {
|
||||
*i, n, err = UnmarshalFloat64(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected float64")
|
||||
})
|
||||
RegisterDecoder("string", func(e interface{}, in []byte) (n int, err error) {
|
||||
if i, ok := e.(*string); ok {
|
||||
*i, n, err = UnmarshalString(in)
|
||||
return n, nil
|
||||
return n, err
|
||||
}
|
||||
return 0, errors.New("ssob: Incompatible type - expected string")
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue