tmppath

command
v0.188.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: BSD-3-Clause Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command tmppath refuses a fixed path in the shared temporary directory in the non-test Go source of a tree.

⛔ WHY IT EXISTS. go-filesystems/ext4 v0.7.1-v0.7.3 wrote logs and raw block dumps to fixed `/tmp/ext4_*` paths, and go-filesystems/kerneljudge <= v0.4.0 wrote a Python script to `os.TempDir()/kerneljudge-ole.py` and EXECUTED it: a fixed name in a directory every user can write is a swap or a symlink away from overwriting a file or running somebody else's code. Both were fixed with a copied source-test guard; this is the one shared gate.

It reads the SYNTAX TREE, not the text: a comment that mentions os.TempDir() does not match (unarchive dmg.go:48, oci limits.go:147 do exactly that). In every non-_test.go file, skipping testdata/ and dot-directories, it flags

  • a string literal that is /tmp or /var/tmp, or begins with either followed by a slash (so "/tmpl" is not one);
  • os.TempDir, ioutil.TempFile and ioutil.TempDir, called or taken as a value (the import is resolved, so an alias is seen and a local variable named os is not).

os.CreateTemp and os.MkdirTemp are NOT flagged: their names are random and created O_EXCL.

An allow comment `//tmppath:ok <reason>` on the same line accepts one finding. A comment with an EMPTY reason is itself a finding and accepts nothing.

⛔ A FILE IT COULD NOT READ IS UNREAD, NEVER CLEAN: a parse error or an unreadable directory is reported UNREAD and makes the status 2.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL