Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
func Cleanup() error
Cleanup removes the entire process-specific temp directory. Note: After Cleanup(), TempDir() will still return the deleted path. Callers should not use TempDir() after Cleanup(). Note: On Windows, directory deletion may fail if files are still open.
func CreateTemp ¶
CreateTemp creates a temporary file, using the process-specific directory when dir is empty
Types ¶
type Root ¶
Root is a traversal-resistant handle to a directory. It embeds *os.Root (https://pkg.go.dev/os#Root), so every name passed to its methods is confined to the directory. Root adds NewRoot and Join.
func NewRoot ¶
NewRoot creates dir (0700) if necessary and opens it as a Root. Like os.OpenRoot, it returns an error if the directory cannot be opened.
func (*Root) Join ¶
Join validates name and returns it joined to the root directory. It rejects names that escape the root either literally (filepath.IsLocal handles "..", absolute paths, and escapes hidden behind a missing component) or through an existing symlink (the embedded os.Root). A name that does not exist yet is allowed, so the caller can resolve a destination before creating it.
The result is a plain string, so it is not protected against a later symlink swap (TOCTOU): use it to hand a confined path to an external tool, and use the os.Root methods directly for ordinary I/O.