From 02665f12db13e12ffcdaccf6c6b9ac3ed24cbfaa Mon Sep 17 00:00:00 2001 From: lawl Date: Fri, 28 Aug 2020 13:39:21 +0200 Subject: [PATCH] Don't hardcode /tmp --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3d7ddee..bf12e02 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "log" "os" + "path/filepath" "syscall" "time" @@ -58,7 +59,8 @@ func main() { } date := time.Now().Format("2006_01_02_03_04_05") - f, err := os.OpenFile(fmt.Sprintf("/tmp/noisetorch-%s.log", date), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) + tmpdir := os.TempDir() + f, err := os.OpenFile(filepath.Join(tmpdir, fmt.Sprintf("noisetorch-%s.log", date)), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { log.Fatalf("error opening file: %v\n", err) }