File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -418,12 +418,19 @@ func (c Cid) ByteLen() int {
418
418
return len (c .str )
419
419
}
420
420
421
- // WriteTo writes the CID bytes to the given writer.
421
+ // WriteBytes writes the CID bytes to the given writer.
422
422
// This method works without incurring any allocation.
423
423
//
424
424
// (See also the ByteLen method for other important operations that work without allocation.)
425
- func (c Cid ) WriteTo (w io.Writer ) (int , error ) {
426
- return io .WriteString (w , c .str )
425
+ func (c Cid ) WriteBytes (w io.Writer ) (int , error ) {
426
+ n , err := io .WriteString (w , c .str )
427
+ if err != nil {
428
+ return n , err
429
+ }
430
+ if n != len (c .str ) {
431
+ return n , fmt .Errorf ("failed to write entire cid string" )
432
+ }
433
+ return n , nil
427
434
}
428
435
429
436
// MarshalBinary is equivalent to Bytes(). It implements the
You can’t perform that action at this time.
0 commit comments