Skip to content

fix(go): handle EOF correctly in model download example of golang bidings#3671

Open
Lumberj3ck wants to merge 1 commit intoggml-org:masterfrom
Lumberj3ck:fix/go-model-download
Open

fix(go): handle EOF correctly in model download example of golang bidings#3671
Lumberj3ck wants to merge 1 commit intoggml-org:masterfrom
Lumberj3ck:fix/go-model-download

Conversation

@Lumberj3ck
Copy link

The Download function inside of golang bindings examples had bug in its read loop:

Data loss on final read: Go's io.Reader contract allows Read to return n > 0
bytes and io.EOF simultaneously (last chunk + end of stream). The original code
checked the error before processing the written bytes, so the final chunk could be
silently dropped and the model file is never fully downloaded.

Before: write happens only if err == nil, and io.EOF propagates as an error to the
caller.
After: bytes are written first (if any), then io.EOF is handled as successful
completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant