From 42bd26302f3ac09bfa170cfeb893f4a69ef5ec2d Mon Sep 17 00:00:00 2001 From: Allan Nava Date: Sat, 2 Nov 2024 20:10:44 +0100 Subject: [PATCH] added file exists fn --- utils/file/file.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/file/file.go b/utils/file/file.go index 089ee12..cdfa7ce 100644 --- a/utils/file/file.go +++ b/utils/file/file.go @@ -9,9 +9,17 @@ func WriteToFile(s []byte, file string) { // f, err := os.Create(file) if err != nil { - //slack.Bug("WriteToFile", err.Error()) log.Fatal(err) } f.Write(s) defer f.Close() } + +// FileExists checks if a file exists and is not a directory. +func FileExists(path string) bool { + info, err := os.Stat(path) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} \ No newline at end of file