Skip to content

Commit

Permalink
Consistent result types/names
Browse files Browse the repository at this point in the history
One function had named return values, keep is consistent with other
functions.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed May 19, 2024
1 parent 12e871f commit f1063a6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ func (e *Encoder) Close() error {
}

// Encode encodes and returns a byte slice.
func Encode(data []byte) (enc []byte, err error) {
func Encode(data []byte) ([]byte, error) {
// Reserve a buffer with overhead room
buf := bytes.NewBuffer(make([]byte, 0, len(data) + (len(data) + 253) / 254))
e := NewEncoder(buf)

if _, err = e.Write(data); err != nil {
if _, err := e.Write(data); err != nil {
return buf.Bytes(), err
}

err = e.Close()
err := e.Close()

return buf.Bytes(), err
}
Expand Down

0 comments on commit f1063a6

Please sign in to comment.