Skip to content

Commit

Permalink
added file exists fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Nov 2, 2024
1 parent db582d3 commit 42bd263
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utils/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit 42bd263

Please sign in to comment.