Compare commits

...

15 commits

Author SHA1 Message Date
Phil Hofer
61bf48afaf Writer: unsafe: modernize to use unsafe.Slice/unsafe.StringData 2026-10-16 14:01:21 -07:00
Phil Hofer
59b5012970 Reader: handle ESPIPE when attempting to Seek
If we get ESPIPE from io.Seeker.Seek, don't try seeking
again and just swallow the error.

Closes #17.
2026-10-16 13:56:36 -07:00
Phil Hofer
716382dfad Reader: Skip: use Seek return value correctly 2026-10-16 13:49:11 -07:00
Sash
d287475b93
Keep bytes when a read returns them with an error. (#38)
Reader.more dropped n > 0 when the error was not EOF. Those bytes are
now buffered, and the error is returned after the caller has them.
2026-10-16 13:41:37 -07:00
Klaus Post
20a13a1f6b
Add PeekByte (#32)
Adds call to get a single byte and add Next happy path.
2024-09-16 07:44:58 -07:00
Michal Hruby
cdc6af6b87
Add Reader.InputOffset (#31)
Add Reader.InputOffset (c.f. `json.Decoder.InputOffset`)
2024-06-12 21:03:59 -07:00
Dan Kegel
fbbf4953d9 unsafestr: update to use unsafe.Slice()
Adds support for tinygo 0.32, thereby fixing https://github.com/philhofer/fwd/issues/29

Passes tests on macos intel:
- go 1.21.9:
	- go test
- go 1.21.9 / tinygo 0.32 prerelease:
	- tinygo test
	- tinygo test -target wasi
2024-06-11 18:42:19 -07:00
Sebastiaan van Stijn
2ae61b800e add go.mod
I used go1.14 as version, to match other projects consuming this
module (e.g. github.com/tinylib/msgp).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-11 07:56:23 -08:00
Sebastiaan van Stijn
ead0d75843 README: re-generate, some manual fixes, add doc reference badge
The godoc2md tool has been deprecated, and is no longer maintained; it
has some bugs which prevent it from generating correct links (so I removed
those).

Added a badge to the documentation on pkg.go.dev, which perhaps should be
used as replacement for the docs in the README itself.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-11 07:56:23 -08:00
Sebastiaan van Stijn
7706de0536 fix some godoc strings, and add doc links
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-11 07:56:23 -08:00
Sebastiaan van Stijn
e22748bc63 gofmt code for current go versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-11 07:56:23 -08:00
Mikkel Kamstrup Erlandsen
b411808a24 Fix panic in Reader.more() because of an unchecked error from the underlying reader.
Fixes https://github.com/philhofer/fwd/issues/25
2022-07-15 08:56:21 -07:00
Cuong Manh Le
8be6da3b9e Fix invalid usage of reflect.SliceHeader
Using plain reflect.SliceHeader struct violates unsafe pointer 6th rule.
2021-08-16 11:01:32 -07:00
Brad Peabody
5c56ac6d0b tinygo support 2021-07-22 12:00:33 -07:00
Phil Hofer
9bcb9cab1b reader: fix Skip(n) where n >= buffer size
The (*Reader).Skip() code did not handle skip sizes
above the buffer size correctly, because the inner
reader loop only looped while 'r.buffered() < n', and
that condition is obviously violated when the reader
successfully buffers more bytes than are to be skipped.

Refactor this method to be a little shorter and hopefully
much clearer (and more correct) and add test coverage that
exercises this code better.
2020-11-24 08:35:57 -08:00
7 changed files with 492 additions and 133 deletions