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
Commits
192377a8
Commit
192377a8
authored
10 years ago
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(commands/optionvalue) use the util.ErrCast()
parent
cc37cc18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
commands/option.go
commands/option.go
+7
-8
No files found.
commands/option.go
View file @
192377a8
package
commands
import
(
"errors"
"reflect"
)
var
CastError
=
errors
.
New
(
"cast error"
)
"github.com/jbenet/go-ipfs/util"
)
// Types of Command options
const
(
...
...
@@ -84,7 +83,7 @@ func (ov OptionValue) Bool() (value bool, found bool, err error) {
}
val
,
ok
:=
ov
.
value
.
(
bool
)
if
!
ok
{
err
=
CastError
err
=
util
.
ErrCast
()
}
return
val
,
ov
.
found
,
err
}
...
...
@@ -95,7 +94,7 @@ func (ov OptionValue) Int() (value int, found bool, err error) {
}
val
,
ok
:=
ov
.
value
.
(
int
)
if
!
ok
{
err
=
CastError
err
=
util
.
ErrCast
()
}
return
val
,
ov
.
found
,
err
}
...
...
@@ -106,7 +105,7 @@ func (ov OptionValue) Uint() (value uint, found bool, err error) {
}
val
,
ok
:=
ov
.
value
.
(
uint
)
if
!
ok
{
err
=
CastError
err
=
util
.
ErrCast
()
}
return
val
,
ov
.
found
,
err
}
...
...
@@ -117,7 +116,7 @@ func (ov OptionValue) Float() (value float64, found bool, err error) {
}
val
,
ok
:=
ov
.
value
.
(
float64
)
if
!
ok
{
err
=
CastError
err
=
util
.
ErrCast
()
}
return
val
,
ov
.
found
,
err
}
...
...
@@ -128,7 +127,7 @@ func (ov OptionValue) String() (value string, found bool, err error) {
}
val
,
ok
:=
ov
.
value
.
(
string
)
if
!
ok
{
err
=
CastError
err
=
util
.
ErrCast
()
}
return
val
,
ov
.
found
,
err
}
...
...
This diff is collapsed.
Click to expand it.
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