fix(bindings/go): return available bytes from Reader.Read - #8260
Open
ClSlaid wants to merge 1 commit into
Open
Conversation
ClSlaid
marked this pull request as ready for review
September 8, 2026 09:09
Member
|
Is this change valid compared with go's semantic? |
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.
Which issue does this PR close?
Closes #8249.
Rationale for this change
Reader.Readrepeats native reads until the caller buffer is full, EOF occurs, or an error occurs. This can delay bytes that storage has already returned.For example, storage returns 3 bytes and the next read blocks. With a 1 MiB caller buffer, the current implementation withholds those 3 bytes. This change returns them before the next native read.
What changes are included in this PR?
io.EOF.io.Copy,io.ReadFull, Seek, and Close.io.ReadFullin behavior tests that require a complete buffer.Are there any user-facing changes?
Reader.Readcan return fewer bytes than the buffer can hold, even before EOF. Callers must process the returned bytes before they check the error.Callers that need a complete buffer must use
io.ReadFull. If a later native read fails, the nextReadcall returns that error.Validation
b6cf44f7) and pass with this change.go vet, and golangci-lint v2.12.2 passed.AI Usage Statement
AI assisted the implementation, regression tests, and documentation. The latency regression tests control the native read results. Actual network latency remains unmeasured.