Skip to content

v0.4.0 — httptimeout rule

Choose a tag to compare

@kidandcat kidandcat released this 25 May 08:46
· 26 commits to master since this release

What's new

New rule: httptimeout — gates HTTP calls and clients that have no timeout.

Flags:

  • http.Get, http.Post, http.Head, http.PostForm (all go through http.DefaultClient, which has zero Timeout)
  • Any call on http.DefaultClient (e.g. http.DefaultClient.Do(req))
  • &http.Client{} / http.Client{} literals with no Timeout field set, or Timeout: 0

Does not flag:

  • &http.Client{Timeout: 30*time.Second} — explicit non-zero
  • &http.Client{Timeout: cfg.Timeout} — non-constant expressions are trusted (the rule's job is to force a deliberate choice, not to verify it)
  • client.Do(req) on a *http.Client variable other than http.DefaultClient — the literal construction is the gate, not every use

Opt-out: `// timeout-ok: ` on the call line or on the opening brace of a multi-line client literal.

Drift fixes in README

  • `errorlint` was previously added without a matching entry in the Rules table; both `errorlint` and `httptimeout` are now listed
  • Coverage count bumped from 11 to 12