## TL;DR

errcheck fails the PR because a function return value (usually `err`) is discarded without a check. Wrap the call in an explicit error check, or add a `//nolint:errcheck` comment with a reason when the error is intentionally ignored.

## Error

```text
main.go:42:13: Error return value of `w.Write` is not checked (errcheck)
```

## Steps

1. Find every errcheck hit: run `golangci-lint run ./...` locally and note each file and line. Expected: the same `Error return value ... is not checked` lines CI reports.
2. If the error matters, handle it explicitly: `if _, err := w.Write(b); err != nil { return err }`. Expected: errcheck passes and the failure path is no longer silent.
3. If the error is intentionally ignored (e.g. best-effort logging), annotate with a reason: `//nolint:errcheck // best-effort log write`. Expected: errcheck skips the line; the reason documents intent.
4. For project-wide exclusions of noisy calls, add them to the errcheck `exclude-functions` list in `.golangci.yml`. Expected: `golangci-lint run ./...` is clean with no new nolint comments.

## When to use

- CI reports `Error return value of ... is not checked (errcheck)` and blocks the PR.
- The flagged call is in Go code and you control the repository.

## When not to use

- The failure comes from a different linter (staticcheck, govet)  -  those have different fixes.
- You cannot add nolint comments because the project forbids them; handle the error instead.

## Tool compatibility

- golangci-lint 1.5x with the errcheck linter enabled.
- Any Go version errcheck supports.

## Variant phrasings

### error return value of `fmt.Sprintf` is not checked

Same fix: assign the value or drop the call if the result is unused.

### errcheck: `defer f.Close()` return not checked

Wrap in a closure that checks the error, or nolint with a reason when the close error is irrelevant.

## Why it happens

errcheck exists because silently discarded errors hide failures. Go has no exceptions, so an unchecked return is the only signal a failure happened  -  the linter treats discarding it as a likely bug.

## Edge cases

- Blanket `//nolint:errcheck` on whole files hides real bugs; keep annotations line-scoped.
- Excluding `fmt.Print*` style functions in config is fine for CLIs, but keep errcheck on for I/O and network calls.
- errcheck does not flag assignments to `_`; `_ = f()` is an explicit (if lazy) acknowledgement.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_tRsXQELwXtMov_ilzBxJ0A
