Don't launch a goroutine when creating temporary directories
tempdir
package is launching a goroutine every time a temporary directory is created. The purpose of the goroutine is to clean up the temporary directory on context cancellation. This doesn't seem very necessary and has downsides.
- In our tests, we look for goroutines that are still running after tests. This deletion goroutine is not synchronized with this and can thus cause flakes.
- If context is canceled, the directory is deleted. If there is still code operating on the directory, that code can fail with unexpected errors rather than returning a context canceled error.
- The clean up is simpler handled by deferring a deletion of the directory when it is created.