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
mf
go-multiaddr
Commits
3f5984c9
Commit
3f5984c9
authored
Jul 03, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
panic handler + construct
parent
47a6842e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
codec.go
codec.go
+9
-1
index.go
index.go
+6
-3
No files found.
codec.go
View file @
3f5984c9
...
...
@@ -31,7 +31,15 @@ func StringToBytes(s string) ([]byte, error) {
return
b
,
nil
}
func
BytesToString
(
b
[]
byte
)
(
string
,
error
)
{
func
BytesToString
(
b
[]
byte
)
(
ret
string
,
err
error
)
{
// panic handler, in case we try accessing bytes incorrectly.
defer
func
()
{
if
e
:=
recover
();
e
!=
nil
{
ret
=
""
err
=
e
.
(
error
)
}
}()
s
:=
""
for
;
len
(
b
)
>
0
;
{
...
...
index.go
View file @
3f5984c9
...
...
@@ -4,7 +4,10 @@ type Multiaddr struct {
Bytes
[]
byte
}
func
NewString
(
s
string
)
*
Multiaddr
{
m
:=
&
Multiaddr
{}
return
m
func
NewString
(
s
string
)
(
*
Multiaddr
,
error
)
{
b
,
err
:=
StringToBytes
(
s
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
Multiaddr
{
Bytes
:
b
},
nil
}
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