Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
059ad352
Commit
059ad352
authored
Feb 20, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Type checking
parent
9bc5c4a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
value.go
ethutil/value.go
+15
-1
No files found.
ethutil/value.go
View file @
059ad352
...
...
@@ -36,7 +36,8 @@ func (val *Value) Len() int {
if
data
,
ok
:=
val
.
Val
.
([]
interface
{});
ok
{
return
len
(
data
)
}
else
if
data
,
ok
:=
val
.
Val
.
([]
byte
);
ok
{
// FIXME
return
len
(
data
)
}
else
if
data
,
ok
:=
val
.
Val
.
(
string
);
ok
{
return
len
(
data
)
}
...
...
@@ -139,6 +140,19 @@ func (val *Value) SliceFromTo(from, to int) *Value {
return
NewValue
(
slice
[
from
:
to
])
}
// TODO More type checking methods
func
(
val
*
Value
)
IsSlice
()
bool
{
return
val
.
Type
()
==
reflect
.
Slice
}
func
(
val
*
Value
)
IsStr
()
bool
{
return
val
.
Type
()
==
reflect
.
String
}
func
(
val
*
Value
)
IsEmpty
()
bool
{
return
(
val
.
IsSlice
()
||
val
.
IsStr
())
&&
val
.
Len
()
==
0
}
// Threat the value as a slice
func
(
val
*
Value
)
Get
(
idx
int
)
*
Value
{
if
d
,
ok
:=
val
.
Val
.
([]
interface
{});
ok
{
...
...
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