func (dec *Decoder) lookupFn(rv reflect.Value) (handler handleDecFn, e error) {
	rk := rv.Kind()
	switch rk {
	case reflect.Map:
		handler = (*Decoder).decodekMap
	case reflect.Struct:
		handler = (*Decoder).decodekStruct
	case reflect.Interface:
		handler = (*Decoder).decodekInterface
	case reflect.String:
		handler = (*Decoder).decodekString
	case reflect.Int:
		handler = (*Decoder).decodekInt
	case reflect.Int8:
		handler = (*Decoder).decodekInt8
	case reflect.Int16:
		handler = (*Decoder).decodekInt16
	case reflect.Int32:
		handler = (*Decoder).decodekInt32
	case reflect.Int64:
		handler = (*Decoder).decodekInt64
	case reflect.Uint:
		handler = (*Decoder).decodekUint
	case reflect.Uint8:
		handler = (*Decoder).decodekUint8
	case reflect.Uint16:
		handler = (*Decoder).decodekUint16
	case reflect.Uint32:
		handler = (*Decoder).decodekUint32
	case reflect.Uint64:
		handler = (*Decoder).decodekUint64
	case reflect.Bool:
		handler = (*Decoder).decodekBool
	case reflect.Float32:
		handler = (*Decoder).decodekFloat32
	case reflect.Float64:
		handler = (*Decoder).decodekFloat64
	case reflect.Slice:
		handler = (*Decoder).decodekSlice
	case reflect.Array:
		handler = (*Decoder).decodekArray
	default:
		handler, e = LookupExtensionFn(rv.Type())
	}
	return handler, e
}
lookup for decode function based on type Kind
package cbor
import (
	"encoding/base64"
	"errors"
	"fmt"
	"io"
	"math/big"
	"mime"
	"net/url"
	"reflect"
	"regexp"
	"time"
)
type handleDecFn func(*Decoder, reflect.Value) error
type extensionDecMap map[uintptr]handleDecFn
var extensionsDec extensionDecMap = make(extensionDecMap)
func (e *extensionDecMap) register(t reflect.Type, fn handleDecFn) error {
	tid := reflect.ValueOf(t).Pointer()
	if _, ok := extensionsDec[tid]; ok {
		return fmt.Errorf("%s type is already registered\n", t)
	}
	extensionsDec[tid] = fn
	return nil
}
func (e *extensionDecMap) lookup(t reflect.Type) (handleDecFn, error) {
	tid := reflect.ValueOf(t).Pointer()
	fn, ok := extensionsDec[tid]
	if !ok {
		return nil, errors.New(fmt.Sprintf(
			"%s not matched as registered extension handler", t))
	}
	return fn, nil
}
func RegisterExtensionFn(t reflect.Type, fn handleDecFn) error {
	return extensionsDec.register(t, fn)
}
func LookupExtensionFn(t reflect.Type) (handleDecFn, error) {
	return extensionsDec.lookup(t)
}
type Decoder struct {
	parser *Parser
	strict bool
}
func NewDecoder(r io.Reader, options ...func(*Decoder)) *Decoder {
	d := &Decoder{parser: &Parser{r: r}, strict: false}
	if len(options) > 0 {
		for _, option := range options {
			option(d)
		}
	}
	return d
}
func (dec *Decoder) Decode(v interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = r.(error)
		}
	}()
	var info byte
	var major Major
	major, info, err = dec.parser.parseInformation()
	if err != nil {
		return err
	}
	if err = dec.checkTypes(reflect.TypeOf(v), major, info); err != nil {
		return err
	}
	switch t := v.(type) {
	case nil:
		return errors.New("can't decode a value into nil")
	case *uint8:
		*t = dec.decodeUint8()
	case *int8:
		*t = dec.decodeInt8()
	case *uint16:
		*t = dec.decodeUint16()
	case *int16:
		*t = dec.decodeInt16()
	case *uint32:
		*t = dec.decodeUint32()
	case *int32:
		*t = dec.decodeInt32()
	case *uint64:
		*t = dec.decodeUint64()
	case *int64:
		*t = dec.decodeInt64()
	case *float16:
		*t = dec.decodeFloat16()
	case *float32:
		if major == cborNC {
			*t = dec.decodeFloat32()
		} else {
			*t = dec.decodeDecimalFraction()
		}
	case *float64:
		*t = dec.decodeFloat64()
	case *big.Int:
		if v.(*big.Int).Sign() < 0 {
			n := dec.decodeNegativeBigNum()
			*t = *n.Neg(n)
		} else {
			n := dec.decodePositiveBigNum()
			*t = *n
		}
	case *time.Time:
		func() {
			defer func() {
				if r := recover(); r != nil {
					*t = dec.decodeEpochDateTime(struct{}{})
				}
			}()
			*t = dec.decodeStringDateTime()
		}()
	case *big.Rat:
		n := dec.decodeBigFloat()
		*t = *n
	case *[]byte:
		*t = dec.decodeBytes()
	case *string:
		*t = dec.decodeString()
	case *bool:
		*t = dec.decodeBool()
	case *interface{}:
		return dec.decode(reflect.ValueOf(v).Elem())
	case reflect.Value:
		return dec.decode(t.Elem())
	default:
		rv := reflect.ValueOf(v)
		if rv.Kind() == reflect.Ptr && !rv.IsNil() || !rv.IsValid() {
			return dec.decode(rv.Elem())
		}
		return &InvalidDecodeError{rv.Type()}
	}
	return err
}
func (dec *Decoder) decode(rv reflect.Value) (err error) {
	if dec.parser.isNil() || dec.parser.isUndef() {
		if rv.Kind() == reflect.Ptr {
			if !rv.IsNil() {
				rv.Set(reflect.Zero(rv.Type()))
			}
			return nil
		}
		if rv.IsValid() && rv.CanSet() {
			rv.Set(reflect.Zero(rv.Type()))
		}
		return nil
	}
	var handler handleDecFn
	handler, err = dec.lookupFn(rv)
	if err != nil {
		return err
	}
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(fmt.Sprint(r))
		}
	}()
	return handler(dec, rv)
}