From: Alan Date: Mon, 16 Mar 2026 11:44:18 +0000 (+0100) Subject: go : handle EOF correctly in model download (#3671) X-Git-Tag: upstream/1.8.4~7 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=79218f51d02ffe70575ef7fba3496dfc7adda027;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp go : handle EOF correctly in model download (#3671) --- diff --git a/bindings/go/examples/go-model-download/main.go b/bindings/go/examples/go-model-download/main.go index 728c6df5..e72262eb 100644 --- a/bindings/go/examples/go-model-download/main.go +++ b/bindings/go/examples/go-model-download/main.go @@ -282,13 +282,20 @@ func Download(ctx context.Context, p io.Writer, model, out string) (string, erro default: // Read body n, err := resp.Body.Read(data) + if n > 0 { + if m, err := w.Write(data[:n]); err != nil { + return path, err + } else { + count += int64(m) + } + } + if err != nil { - DownloadReport(p, pct, count, resp.ContentLength) - return path, err - } else if m, err := w.Write(data[:n]); err != nil { + if err == io.EOF { + DownloadReport(p, pct, count, resp.ContentLength) + return path, nil + } return path, err - } else { - count += int64(m) } } }