func UnmarshalDict(t Dict, v interface{}) error {
	var keys = t.Key.Data.([]string)
	var vals = t.Value.Data.([]*K)
	vv := reflect.ValueOf(v)
	if vv.Kind() != reflect.Ptr || vv.IsNil() {
		return errors.New("Invalid target type. Should be non null pointer")
	}
	vv = reflect.Indirect(vv)
	for i := range keys {
		val := vals[i].Data
		fv := vv.FieldByName(titleInitial(keys[i]))
		if !fv.IsValid() {
			continue
		}
		if fv.CanSet() && reflect.TypeOf(val).AssignableTo(fv.Type()) {
			fv.Set(reflect.ValueOf(val))
		}
	}
	return nil
}
UnmarshalDict decodes dict to a struct
package kdb
import (
	"bytes"
	"errors"
	"fmt"
	"math"
	"reflect"
	"time"
	"unicode"
)
type ReqType int8
const (
	ASYNC    ReqType = 0
	SYNC             = 1
	RESPONSE         = 2
)
type Attr int8
const (
	NONE Attr = iota
	SORTED
	UNIQUE
	PARTED
	GROUPED
)
const (
	K0 int8 = 0  
	KB int8 = 1   
	UU int8 = 2   
	KG int8 = 4   
	KH int8 = 5   
	KI int8 = 6   
	KJ int8 = 7   
	KE int8 = 8   
	KF int8 = 9   
	KC int8 = 10  
	KS int8 = 11  
	KP int8 = 12  
	KM int8 = 13  
	KD int8 = 14  
	KZ int8 = 15  
	KN int8 = 16  
	KU int8 = 17  
	KV int8 = 18  
	KT int8 = 19  
	XT int8 = 98   
	XD int8 = 99   
	SD int8 = 127  
	KFUNC      int8 = 100
	KFUNCUP    int8 = 101  
	KFUNCBP    int8 = 102  
	KFUNCTR    int8 = 103  
	KPROJ      int8 = 104  
	KCOMP      int8 = 105  
	KEACH      int8 = 106  
	KOVER      int8 = 107  
	KSCAN      int8 = 108  
	KPRIOR     int8 = 109  
	KEACHRIGHT int8 = 110  
	KEACHLEFT  int8 = 111  
	KDYNLOAD   int8 = 112  
	KERR int8 = -128  
)
type ipcHeader struct {
	ByteOrder   byte
	RequestType ReqType
	Compressed  byte
	Reserved    byte
	MsgSize     uint32
}
const Nh int16 = math.MinInt16
const Wh int16 = math.MaxInt16
const Ni int32 = math.MinInt32
const Wi int32 = math.MaxInt32
const Nj int64 = math.MinInt64
const Wj int64 = math.MaxInt64
var Ne = float32(math.NaN())
var We = float32(math.Inf(+1))
var Nf = math.NaN()
var Wf = math.Inf(+1)
type K struct {
	Type int8
	Attr Attr
	Data interface{}
}
func Int(x int32) *K {
	return &K{-KI, NONE, x}
}
func IntV(x []int32) *K {
	return &K{KI, NONE, x}
}
func Long(x int64) *K {
	return &K{-KJ, NONE, x}
}
func LongV(x []int64) *K {
	return &K{KJ, NONE, x}
}
func Real(x float32) *K {
	return &K{-KE, NONE, x}
}
func RealV(x []float32) *K {
	return &K{KE, NONE, x}
}
func Float(x float64) *K {
	return &K{-KF, NONE, x}
}
func FloatV(x []float64) *K {
	return &K{KF, NONE, x}
}
func Error(x error) *K {
	return &K{KERR, NONE, x}
}
func Symbol(x string) *K {
	return &K{-KS, NONE, x}
}
func SymbolV(x []string) *K {
	return &K{KS, NONE, x}
}
func Date(x time.Time) *K {
	return &K{-KD, NONE, x}
}
func DateV(x []time.Time) *K {
	return &K{KD, NONE, x}
}
func Atom(t int8, x interface{}) *K {
	return &K{t, NONE, x}
}
func NewList(x ...*K) *K {
	return &K{K0, NONE, x}
}
func NewFunc(ctx, body string) *K {
	return &K{KFUNC, NONE, Function{Namespace: ctx, Body: body}}
}
func (k *K) Len() int {
	if k.Type < K0 || k.Type >= KFUNC {
		return 1
	} else if k.Type >= K0 && k.Type <= KT {
		return reflect.ValueOf(k.Data).Len()
	} else if k.Type == XD {
		return k.Data.(Dict).Key.Len()
	} else if k.Type == XT {
		return k.Data.(Table).Data[0].Len()
	} else {
		return -1
	}
}
func (k *K) Index(i int) interface{} {
	if k.Type < K0 || k.Type > XT {
		return nil
	}
	if k.Len() == 0 {
		if k.Type == K0 {
			return &K{K0, NONE, make([]*K, 0)}
		}
		return nil
	}
	if k.Type >= K0 && k.Type <= KT {
		return reflect.ValueOf(k.Data).Index(i).Interface()
	}
	if k.Type != XT {
		return nil
	}
	var t = k.Data.(Table)
	return &K{XD, NONE, t.Index(i)}
}
var attrPrint = []string{NONE: "", SORTED: "`s#", UNIQUE: "`u#", PARTED: "`p#", GROUPED: "`g#"}
var unaryops = []string{"::", "+:", "-:", "*:", "%:", "&:", "|:", "^:", "=:", "<:", ">:", "$:", ",:", "#:", "_:", "~:", "!:", "?:", "@:", ".:", "0::", "1::", "2::", "avg", "last", "sum", "prd", "min", "max", "exit", "getenv", "abs", "sqrt", "log", "exp", "sin", "asin", "cos", "acos", "tan", "atan", "enlist", 255: ""}
var binaryops = []string{":", "+", "-", "*", "%", "&", "|", "^", "=", "<", ">", "$", ",", "#", "_", "~", "!", "?", "@", ".", "0:", "1:", "2:", "in", "within", "like", "bin", "ss", "insert", "wsum", "wavg", "div", "xexp", "setenv"}
var ternaryops = []string{"'", "/", "\\"}
var adverbs = []string{106: "'", 107: "/", 108: "\\", 109: "':", 110: "/:", 111: "\\:"}
func (k K) String() string {
	if k.Type < K0 {
		return fmt.Sprint(k.Data)
	}
	if k.Type > K0 && k.Type <= KT {
		return fmt.Sprint(attrPrint[k.Attr], k.Data)
	}
	switch k.Type {
	case K0:
		list := k.Data.([]*K)
		var buf bytes.Buffer
		buf.WriteString(attrPrint[k.Attr])
		buf.WriteString("(")
		for i, l := range list {
			buf.WriteString(l.String())
			if i < len(list)-1 {
				buf.WriteString(";")
			}
		}
		buf.WriteString(")")
		return buf.String()
	case XD:
		return attrPrint[k.Attr] + k.Data.(Dict).String()
	case XT:
		return attrPrint[k.Attr] + k.Data.(Table).String()
	case KFUNC:
		return k.Data.(Function).Body
	case KFUNCUP:
		return unaryops[k.Data.(byte)]
	case KFUNCBP:
		return binaryops[k.Data.(byte)]
	case KFUNCTR:
		return ternaryops[k.Data.(byte)]
	case KPROJ, KCOMP:
		list := k.Data.([]*K)
		var buf bytes.Buffer
		for _, l := range list {
			buf.WriteString(l.String())
		}
		return buf.String()
	case KEACH, KOVER, KSCAN, KPRIOR, KEACHRIGHT, KEACHLEFT:
		return k.Data.(*K).String() + adverbs[k.Type]
	default:
		return "unknown"
	}
}
var ErrBadMsg = errors.New("Bad Message")
var ErrBadHeader = errors.New("Bad header")
var ErrSyncRequest = errors.New("nosyncrequest")
var qEpoch = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)
type Month int32
func (m Month) String() string {
	return fmt.Sprintf("%v.%02vm", 2000+int(m/12), int(m)%12)
}
type Minute time.Time
func (m Minute) String() string {
	time := time.Time(m)
	return fmt.Sprintf("%02v:%02v", time.Hour(), time.Minute())
}
type Second time.Time
func (s Second) String() string {
	time := time.Time(s)
	return fmt.Sprintf("%02v:%02v:%02v", time.Hour(), time.Minute(), time.Second())
}
type Time time.Time
func (t Time) String() string {
	time := time.Time(t)
	return fmt.Sprintf("%02v:%02v:%02v.%03v", time.Hour(), time.Minute(), time.Second(), time.Nanosecond()/1000000)
}
type Table struct {
	Columns []string
	Data    []*K
}
func NewTable(cols []string, data []*K) *K {
	return &K{XT, NONE, Table{cols, data}}
}
func (tbl *Table) Index(i int) Dict {
	var d = Dict{}
	d.Key = &K{KS, NONE, tbl.Columns}
	vslice := make([]*K, len(tbl.Columns))
	d.Value = &K{K0, NONE, vslice}
	for ci := range tbl.Columns {
		kd := tbl.Data[ci].Index(i)
		dtype := tbl.Data[ci].Type
		if dtype == K0 {
			dtype = kd.(*K).Type
		} else if dtype > K0 && dtype <= KT {
			dtype = -dtype
		}
		vslice[ci] = &K{dtype, NONE, kd}
	}
	return d
}
func (tbl Table) String() string {
	var buf bytes.Buffer
	buf.WriteString("+")
	buf.WriteString(fmt.Sprint(tbl.Columns))
	buf.WriteString("!")
	buf.WriteString("(")
	for i, l := range tbl.Data {
		buf.WriteString(l.String())
		if i < len(tbl.Data)-1 {
			buf.WriteString(";")
		}
	}
	buf.WriteString(")")
	return buf.String()
}
type Dict struct {
	Key   *K
	Value *K
}
func NewDict(k, v *K) *K {
	return &K{XD, NONE, Dict{k, v}}
}
func (d Dict) String() string {
	return fmt.Sprintf("%v!%v", d.Key.Data, d.Value.Data)
}
func titleInitial(str string) string {
	for i, v := range str {
		return string(unicode.ToTitle(v)) + str[i+1:]
	}
	return ""
}