Skip to content

First release

Latest

Choose a tag to compare

@ChenJesse ChenJesse released this 14 Jan 19:44
go prefixedwriter: fix short write error case

In certain cases, formatting as JSON actually reduces the number of bytes.
This leads to the bufio.Writer that wraps this returning `short write` error
because the number of bytes returned is less than expected.

We just want to return the original number of bytes, since we know that we are
doing some string manipulation and we are OK with that.

See: https://pkg.go.dev/io#Writer
```
Write writes len(p) bytes from p to the underlying data stream. It returns the
number of bytes written from p (0 <= n <= len(p)) and any error encountered
that caused the write to stop early. Write must return a non-nil error if it
returns n < len(p).
```