Unverified Commit 1114463b authored by Whyrusleeping's avatar Whyrusleeping Committed by GitHub

Merge pull request #63 from ipfs/better-arrays

Better arrays
parents e8d80ffd c7f8666e
1.0.6: QmWGgKRz5S24SqaAapF5PPCfYfLT7MexJZewN5M82CQTzs
1.0.7: QmRv6ddf7gkiEgBs1LADv3vC1mkVGPZEfByoiiVybjE9Mc
......@@ -35,3 +35,23 @@ func TestMakeTypedEncoder(t *testing.T) {
t.Fatal("expected: ", expErr)
}
}
func TestMakeTypedEncoderArrays(t *testing.T) {
f := MakeTypedEncoder(func(req *Request, w io.Writer, v []fooTestObj) error {
if len(v) != 2 {
return fmt.Errorf("bad")
}
return nil
})
req := &Request{}
encoderFunc := f(req)
buf := new(bytes.Buffer)
encoder := encoderFunc(buf)
if err := encoder.Encode([]fooTestObj{{true}, {false}}); err != nil {
t.Fatal(err)
}
}
......@@ -47,6 +47,6 @@
"license": "MIT",
"name": "go-ipfs-cmds",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.0.6"
"version": "1.0.7"
}
......@@ -76,6 +76,10 @@ func (r *readerResponse) RawNext() (interface{}, error) {
r.once.Do(func() { close(r.emitted) })
v := m.Get()
// because working with pointers to arrays is annoying
if t := reflect.TypeOf(v); t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Slice {
v = reflect.ValueOf(v).Elem().Interface()
}
return v, nil
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment