func (shd *shard) decodeSpan(sid common.SpanId, buf []byte) (*common.Span, error) { r := bytes.NewBuffer(buf) decoder := gob.NewDecoder(r) data := common.SpanData{} err := decoder.Decode(&data) if err != nil { return nil, err } // Gob encoding translates empty slices to nil. Reverse this so that we're always dealing with // non-nil slices. if data.Parents == nil { data.Parents = []common.SpanId{} } return &common.Span{Id: common.SpanId(sid), SpanData: data}, nil }
func (shd *shard) decodeSpan(sid common.SpanId, buf []byte) (*common.Span, error) { r := bytes.NewBuffer(buf) mh := new(codec.MsgpackHandle) mh.WriteExt = true decoder := codec.NewDecoder(r, mh) data := common.SpanData{} err := decoder.Decode(&data) if err != nil { return nil, err } if data.Parents == nil { data.Parents = []common.SpanId{} } return &common.Span{Id: common.SpanId(sid), SpanData: data}, nil }