This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 35 · Aug 25 – 31, 2025

testing: use $GOTMPDIR for temporary files when set

Worth knowingstdlib

What changed
The testing package will now use the $GOTMPDIR environment variable for temporary files when it is set.
Production impact
The source does not say.
Try it
Run a test with export GOTMPDIR=/tmp/go-test and observe that t.TempDir() creates files in that directory.
Source
github.com/golang/go/issues/61585

Understand it, then run it

The testing package creates temporary files when a test needs them. Before the change, it always used the system’s temporary directory, the one returned by os.TempDir(). Now, if the environment variable GOTMPDIR is set, the testing package will use that directory instead. This lets developers run tests on machines where the normal temp directory is locked or otherwise unsuitable, without changing the rest of the system.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed