From af076e6b2e36783728f28d8a879461a6cdf14349 Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Wed, 11 Feb 2026 17:41:55 -0800 Subject: [PATCH] Check unchecked write errors Handle return values from w.Write in embedmd.go and io.Copy in main.go that were previously silently ignored. Co-Authored-By: Claude Opus 4.6 --- embedmd/embedmd.go | 4 +++- main.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/embedmd/embedmd.go b/embedmd/embedmd.go index 7135f75..c59cc2a 100644 --- a/embedmd/embedmd.go +++ b/embedmd/embedmd.go @@ -105,7 +105,9 @@ func (e *embedder) runCommand(w io.Writer, cmd *command) error { } fmt.Fprintln(w, "```"+cmd.lang) - w.Write(b) + if _, err := w.Write(b); err != nil { + return err + } fmt.Fprintln(w, "```") return nil } diff --git a/main.go b/main.go index bdbe8d4..ad7eaa7 100644 --- a/main.go +++ b/main.go @@ -172,8 +172,8 @@ func processFile(path string, rewrite, doDiff bool) (foundDiff bool, err error) return false, f.Truncate(int64(n)) } - io.Copy(stdout, buf) - return false, nil + _, err = io.Copy(stdout, buf) + return false, err } func diff(a, b string) (string, error) {