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-cid
Commits
75caa6bd
Commit
75caa6bd
authored
May 01, 2020
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid calling the method WriteTo if we don't satisfy its contract
parent
c1c89c20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
cid.go
cid.go
+10
-3
No files found.
cid.go
View file @
75caa6bd
...
@@ -418,12 +418,19 @@ func (c Cid) ByteLen() int {
...
@@ -418,12 +418,19 @@ func (c Cid) ByteLen() int {
return
len
(
c
.
str
)
return
len
(
c
.
str
)
}
}
// Write
To
writes the CID bytes to the given writer.
// Write
Bytes
writes the CID bytes to the given writer.
// This method works without incurring any allocation.
// This method works without incurring any allocation.
//
//
// (See also the ByteLen method for other important operations that work without allocation.)
// (See also the ByteLen method for other important operations that work without allocation.)
func
(
c
Cid
)
WriteTo
(
w
io
.
Writer
)
(
int
,
error
)
{
func
(
c
Cid
)
WriteBytes
(
w
io
.
Writer
)
(
int
,
error
)
{
return
io
.
WriteString
(
w
,
c
.
str
)
n
,
err
:=
io
.
WriteString
(
w
,
c
.
str
)
if
err
!=
nil
{
return
n
,
err
}
if
n
!=
len
(
c
.
str
)
{
return
n
,
fmt
.
Errorf
(
"failed to write entire cid string"
)
}
return
n
,
nil
}
}
// MarshalBinary is equivalent to Bytes(). It implements the
// MarshalBinary is equivalent to Bytes(). It implements the
...
...
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