We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to run the following code:
package main import "github.com/vmihailenco/msgpack" import "fmt" import "unsafe" import "reflect" type Test struct { A uint16 B uint16 C string D [4]string E [2]int64 } func main() { test := Test{ A: uint16(1), B: uint16(25565), C: "yolotest", D: [4]string{"a", "b", "c", "d"}, E: [2]int64{int64(1348293849324), int64(4345345345)}, } buf, err := msgpack.Marshal(test) if err != nil { fmt.Printf("%s\n", err) } fmt.Printf("%s\n", buf) fmt.Printf("%s\n", len(buf)) fmt.Printf("%s\n", unsafe.Sizeof(test)) newzy := Test{} msgpack.Unmarshal(buf, &newzy) fmt.Printf("%s\n", newzy) fmt.Printf("%s\n", unsafe.Sizeof(newzy)) }
I get the following error:
panic: reflect: call of reflect.Value.IsNil on array Value goroutine 1 [running]: reflect.Value.IsNil(0x46ca98, 0xf840000e18, 0x112, 0x4aa070, 0x46ca98, ...) /usr/lib/go/src/pkg/reflect/value.go:895 +0x130 github.com/vmihailenco/msgpack.(*Encoder).encodeSlice(0xf84002f220, 0x46ca98, 0xf840000e18, 0x112, 0x1, ...)
This happens both when trying to compact a struct, and a single slice like:
func main() { test := [4]string{"a", "b", "c", "d"} buf, err := msgpack.Marshal(test) fmt.Printf("err: %s\n", err) newzy := make([]string, 4) msgpack.Unmarshal(buf, &newzy) fmt.Printf("V: %s\n", newzy) }
If one was to comment the invalid IsNil call, you get the following error:
panic: interface conversion: interface is [4]string, not []string goroutine 1 [running]: github.com/vmihailenco/msgpack.(*Encoder).encodeSlice(0xf84002f220, 0x46ca98, 0xf840000e18, 0x112, 0x1, ...)
The text was updated successfully, but these errors were encountered:
2f06bb6
Fixed. You probably need to read this http://blog.golang.org/slices , because [4]string is an array, not a slice.
Sorry, something went wrong.
TIL. Thanks for the patch! 👍
No branches or pull requests
Trying to run the following code:
I get the following error:
This happens both when trying to compact a struct, and a single slice like:
If one was to comment the invalid IsNil call, you get the following error:
The text was updated successfully, but these errors were encountered: