Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTmpFriendDir ¶
IsTmpFriendDir returns true if we are in a tmpfriend dir.
func RootTempDir ¶
RootTempDir creates a new TMPDIR tied to this process, as well as cleaning up TMPDIRs from defunct processes.
TMPDIR is used by both ioutil.TempDir and os.TempDir. The callback returned will cleanup TMPDIR and restore its old value. Note this function is not safe to use concurently since modifying the environment is shared by the whole process.
To use put code like this somewhere like `func main()`
if !IsTmpFriendDir("") { f, err := tmpfriend.RootTempDir("") if err != nil { return err } defer f() } ...
func SetupOrNOOP ¶
func SetupOrNOOP() func()
SetupOrNOOP is the expected way to use tmpfriend. It is a wrapper around RootTempDir and IsTmpFriendDir. It will always return a cleanup function, and will do a NOOP under error.
cleanup := tmpfriend.SetupOrNOOP() defer cleanup() ...
Types ¶
This section is empty.