/usr/share/gocode/src/github.com/siddontang/rdb/encode.go is in golang-github-siddontang-rdb-dev 0.0~git20150307.0.fc89ed2-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | package rdb
import (
"bytes"
"fmt"
"github.com/cupcake/rdb"
)
func Dump(obj interface{}) ([]byte, error) {
var buf bytes.Buffer
e := rdb.NewEncoder(&buf)
switch v := obj.(type) {
case String:
e.EncodeType(rdb.TypeString)
e.EncodeString(v)
case Hash:
e.EncodeType(rdb.TypeHash)
e.EncodeLength(uint32(len(v)))
for i := 0; i < len(v); i++ {
e.EncodeString(v[i].Field)
e.EncodeString(v[i].Value)
}
case List:
e.EncodeType(rdb.TypeList)
e.EncodeLength(uint32(len(v)))
for i := 0; i < len(v); i++ {
e.EncodeString(v[i])
}
case Set:
e.EncodeType(rdb.TypeSet)
e.EncodeLength(uint32(len(v)))
for i := 0; i < len(v); i++ {
e.EncodeString(v[i])
}
case ZSet:
e.EncodeType(rdb.TypeZSet)
e.EncodeLength(uint32(len(v)))
for i := 0; i < len(v); i++ {
e.EncodeString(v[i].Member)
e.EncodeFloat(v[i].Score)
}
default:
return nil, fmt.Errorf("invalid dump type %T", obj)
}
e.EncodeDumpFooter()
return buf.Bytes(), nil
}
|