Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
c758a4cf
Commit
c758a4cf
authored
Feb 02, 2018
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MakeTypedEncoder bug
parent
c680937a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
3 deletions
+44
-3
.gx/lastpubver
.gx/lastpubver
+1
-1
encoding.go
encoding.go
+5
-1
encoding_test.go
encoding_test.go
+37
-0
package.json
package.json
+1
-1
No files found.
.gx/lastpubver
View file @
c758a4cf
1.0.
5
: Qm
Z9hww8R3FKrDRCYPxhN13m6XgjPDpaSvdUfisPvERzXz
1.0.
6
: Qm
WGgKRz5S24SqaAapF5PPCfYfLT7MexJZewN5M82CQTzs
encoding.go
View file @
c758a4cf
...
@@ -103,7 +103,11 @@ func MakeTypedEncoder(f interface{}) func(*Request) func(io.Writer) Encoder {
...
@@ -103,7 +103,11 @@ func MakeTypedEncoder(f interface{}) func(*Request) func(io.Writer) Encoder {
reflect
.
ValueOf
(
i
),
reflect
.
ValueOf
(
i
),
})
})
return
out
[
0
]
.
Interface
()
.
(
error
)
err
,
ok
:=
out
[
0
]
.
Interface
()
.
(
error
)
if
ok
{
return
err
}
return
nil
})
})
}
}
...
...
encoding_test.go
0 → 100644
View file @
c758a4cf
package
cmds
import
(
"bytes"
"fmt"
"io"
"testing"
)
type
fooTestObj
struct
{
Good
bool
}
func
TestMakeTypedEncoder
(
t
*
testing
.
T
)
{
expErr
:=
fmt
.
Errorf
(
"command fooTestObj failed"
)
f
:=
MakeTypedEncoder
(
func
(
req
*
Request
,
w
io
.
Writer
,
v
*
fooTestObj
)
error
{
if
v
.
Good
{
return
nil
}
return
expErr
})
req
:=
&
Request
{}
encoderFunc
:=
f
(
req
)
buf
:=
new
(
bytes
.
Buffer
)
encoder
:=
encoderFunc
(
buf
)
if
err
:=
encoder
.
Encode
(
&
fooTestObj
{
true
});
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
encoder
.
Encode
(
&
fooTestObj
{
false
});
err
!=
expErr
{
t
.
Fatal
(
"expected: "
,
expErr
)
}
}
package.json
View file @
c758a4cf
...
@@ -47,6 +47,6 @@
...
@@ -47,6 +47,6 @@
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
"name"
:
"go-ipfs-cmds"
,
"name"
:
"go-ipfs-cmds"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"version"
:
"1.0.
5
"
"version"
:
"1.0.
6
"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment