Repository navigation
Redesign readers to caller-owned channels + error return - #3
Merged
Merged
Conversation
…dernize to Go 1.24
- Close the index channel when the scanner goroutine finishes so
'for range' over it terminates instead of hanging forever; document
that callers must drain both channels to avoid deadlocking the
split function.
- Fix ExampleFindReaderIndex's // Output: comment — the example prints
both match and index ("stream of [20 32]"), so go test failed.
- Rename steamregexindex(.go|_test.go) -> streamregexindex(.go|_test.go).
- Bump go.mod go directive to 1.24; gofmt/go vet clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…return BREAKING API CHANGE: both readers now accept caller-owned channels and return an error instead of returning a channel; they run synchronously (no internal goroutine) and never close the channels — the caller owns concurrency, error handling, and channel lifecycle. - FindReader(ctx, re, maxMatchLength, reader, matches chan<- string) error - FindReaderIndex(ctx, re, maxMatchLength, reader, matches chan<- string, indexes chan<- []int) error - Return scanner.Err() at EOF so reader failures surface instead of looking like a clean EOF; return ctx.Err() on cancellation. - FindReaderIndex still emits each index just before its match; document that the caller must drain both channels (buffer indexes by 1) or it deadlocks. - Update both example tests, unit tests, and README to the new style. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vertoforce
pushed a commit
that referenced
this pull request
Oct 24, 2026
Redesign readers to caller-owned channels + error return
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redesigns the two reader functions to a caller-managed style (modeled on go-ioc's
GetIOCsReader).FindReader/FindReaderIndexnow accept caller-owned channels and return anerrorinstead of returning a channel.scanner.Err()at EOF so a read failure surfaces instead of looking like a clean EOF; returnctx.Err()on cancellation.FindReaderIndexstill emits each index just before its match; caller must drain both channels (buffer indexes by 1) or it deadlocks — documented.Tests:
gofmt/go vet ./...clean,go test -race ./...passes (Go 1.24).Includes the earlier cleanup fixes from #2 since master does not yet contain them.
🤖 Generated with Claude Code