forked from kevadesu/forgejo
Upgrade xorm to v1.1.0 (#15869)
This commit is contained in:
parent
e2f39c2b64
commit
f6be429781
55 changed files with 1309 additions and 438 deletions
9
vendor/xorm.io/xorm/caches/encode.go
generated
vendored
9
vendor/xorm.io/xorm/caches/encode.go
generated
vendored
|
@ -13,22 +13,26 @@ import (
|
|||
"io"
|
||||
)
|
||||
|
||||
// md5 hash string
|
||||
// Md5 return md5 hash string
|
||||
func Md5(str string) string {
|
||||
m := md5.New()
|
||||
io.WriteString(m, str)
|
||||
return fmt.Sprintf("%x", m.Sum(nil))
|
||||
}
|
||||
|
||||
// Encode Encode data
|
||||
func Encode(data interface{}) ([]byte, error) {
|
||||
//return JsonEncode(data)
|
||||
return GobEncode(data)
|
||||
}
|
||||
|
||||
// Decode decode data
|
||||
func Decode(data []byte, to interface{}) error {
|
||||
//return JsonDecode(data, to)
|
||||
return GobDecode(data, to)
|
||||
}
|
||||
|
||||
// GobEncode encode data with gob
|
||||
func GobEncode(data interface{}) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
enc := gob.NewEncoder(&buf)
|
||||
|
@ -39,12 +43,14 @@ func GobEncode(data interface{}) ([]byte, error) {
|
|||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// GobDecode decode data with gob
|
||||
func GobDecode(data []byte, to interface{}) error {
|
||||
buf := bytes.NewBuffer(data)
|
||||
dec := gob.NewDecoder(buf)
|
||||
return dec.Decode(to)
|
||||
}
|
||||
|
||||
// JsonEncode encode data with json
|
||||
func JsonEncode(data interface{}) ([]byte, error) {
|
||||
val, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
|
@ -53,6 +59,7 @@ func JsonEncode(data interface{}) ([]byte, error) {
|
|||
return val, nil
|
||||
}
|
||||
|
||||
// JsonDecode decode data with json
|
||||
func JsonDecode(data []byte, to interface{}) error {
|
||||
return json.Unmarshal(data, to)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue