update vendor

This commit is contained in:
deepzz0
2017-07-11 23:50:01 +08:00
parent e1ec5cd08a
commit c18d9c0bef
107 changed files with 8347 additions and 126 deletions

View File

@@ -0,0 +1,19 @@
package jsonutil
import (
"encoding/json"
"reflect"
"unsafe"
)
// ----------------------------------------------------------
func Unmarshal(data string, v interface{}) error {
sh := *(*reflect.StringHeader)(unsafe.Pointer(&data))
arr := (*[1<<30]byte)(unsafe.Pointer(sh.Data))
return json.Unmarshal(arr[:sh.Len], v)
}
// ----------------------------------------------------------

View File

@@ -0,0 +1,19 @@
package jsonutil
import (
"testing"
)
func Test(t *testing.T) {
var ret struct {
Id string `json:"id"`
}
err := Unmarshal(`{"id": "123"}`, &ret)
if err != nil {
t.Fatal("Unmarshal failed:", err)
}
if ret.Id != "123" {
t.Fatal("Unmarshal uncorrect:", ret.Id)
}
}