korrents

korrents · piece

On Using Go's `t.Parallel()`

Brandur Leach · 26 Aug 2023

Read the piece on brandur.org ↗

2 korrents from this piece ↓

Brandur Leach did not write this page.

Every claim below was made in this piece, quoted word for word and numbered in the order the piece makes them, so you can read it there rather than take our word for it. The sentence above each quote is our reading of the claim, not their wording. Each quote was checked against a stored copy of the page at build time; where the two differ, the quote is the fact.

  1. As some packages grow to be large, parallel testing will keep them fast, and annotating tests with t.Parallel() from the beginning is a lot easier than going back to add it to every test case and fix parallelism problems later on.
  2. Our tests use goleak to detect any accidentally leaked goroutines, a practice that I'd recommend since leaking goroutines without realizing it is easily one of Go's top footguns.

Keep reading