Compare commits

...

34 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
Janusz Marcinkiewicz
414ae1bb9e Add Reader/Writer constructors with custom buffer 2020-07-30 09:54:17 -07:00
Philip Hofer
bb6d471dc9 Merge pull request #15 from EdwardBetts/spelling
correct spelling mistake
2017-09-05 14:21:22 -07:00
Edward Betts
7f183dbc6f correct spelling mistake 2017-09-01 12:51:31 +01:00
Philip Hofer
1612a29811 Merge pull request #14 from jsternberg/master
Discard io.EOF when more than 0 bytes have been read
2017-06-16 13:40:54 -07:00
Jonathan A. Sternberg
2eb7ce4c0c Discard io.EOF when more than 0 bytes have been read
Some `io.Reader` instances can return `io.EOF` with a non-zero number of
bytes and will then return 0 bytes with the `io.EOF` error on the next
read. This interferes with the expectation that `io.EOF` meant that no
bytes had been read.

Discard the error and buffer the read data so these types of `io.Reader`
instances still work properly.

Fixes #13.
2017-06-16 14:59:17 -05:00
Philip Hofer
98c11a7a6e Merge pull request #12 from shawnps/master
rerun godoc2md
2016-01-28 19:59:39 -08:00
shawnps
222b992a5a rerun godoc2md 2016-01-29 12:39:26 +09:00
Philip Hofer
f603d16432 maximize read buffer size
Before, if r.n == len(r.data), then r.data wouldn't be re-sliced
to r.data[:0], which would call Read() to be called with a smaller
buffer than necessary.
2016-01-25 15:22:51 -08:00
Philip Hofer
19fb8901f0 Merge pull request #11 from shawnps/patch-4
typo
2016-01-21 18:18:20 -08:00
Shawn Smith
d530c40f9c typo 2016-01-21 18:04:19 -08:00
Philip Hofer
f429d72be3 Merge pull request #9 from shawnps/patch-1
fix typo
2015-12-31 09:42:20 -05:00
Philip Hofer
192fd99266 Merge pull request #10 from shawnps/patch-2
fix typos
2015-12-31 09:41:51 -05:00
Shawn Smith
50547e3e2f fix typos 2015-12-31 14:22:00 +09:00
Shawn Smith
901a52c61b fix typo 2015-12-31 14:21:05 +09:00
Philip Hofer
92647f2bd9 Merge pull request #8 from philhofer/better-reading
better reading
2015-11-19 18:40:02 -08:00
Philip Hofer
3628caea4a better reading 2015-11-19 18:13:28 -08:00
Philip Hofer
8fd9a4b750 add MIT license 2015-10-05 11:02:59 -07:00
Phil Hofer
4dbda5e290 Next() should realloc correctly 2015-07-22 15:15:02 -07:00
Philip Hofer
dff36b82bd Merge pull request #6 from philhofer/hotfix-peek
fix #4 and #5
2015-07-21 13:59:32 -07:00
10 changed files with 709 additions and 164 deletions