From 0c0c8051c5e416593817f3a3def1b6dd26aa7299 Mon Sep 17 00:00:00 2001 From: Sandra Snan Date: Wed, 27 Dec 2023 13:38:03 +0100 Subject: [PATCH] Exit with error if it can't create the directory I was having crashes & panics and it turned out to be because I had a socket named /tmp/mangal. --- where/where.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/where/where.go b/where/where.go index def252a4..e5bcb211 100644 --- a/where/where.go +++ b/where/where.go @@ -6,6 +6,7 @@ import ( "github.com/metafates/mangal/key" "github.com/samber/lo" "github.com/spf13/viper" + "log" "os" "path/filepath" ) @@ -15,7 +16,9 @@ const EnvConfigPath = "MANGAL_CONFIG_PATH" // mkdir creates a directory and all parent directories if they don't exist // will return the path of the directory func mkdir(path string) string { - lo.Must0(filesystem.Api().MkdirAll(path, os.ModePerm)) + if filesystem.Api().MkdirAll(path, os.ModePerm) != nil { + log.Fatalf("Error: could not create directory %s", path) + } return path }