package etcd_tools import ( "encoding/json" "github.com/coreos/etcd/mvcc/mvccpb" ) type Pair struct { Key string Value string Bytes []byte Created int64 Modified int64 Version int64 Lease int64 } func NewPair(kv *mvccpb.KeyValue) *Pair { return &Pair{string(kv.Key), string(kv.Value), kv.Value, kv.CreateRevision, kv.ModRevision, kv.Version, kv.Lease} } func Pairs(kvs []*mvccpb.KeyValue) []*Pair { result := make([]*Pair, 0, len(kvs)) for _, kv := range kvs { result = append(result, NewPair(kv)) } return result } func (p *Pair) Fill(v *interface{}) error { return json.Unmarshal(p.Bytes, v) }