diff options
Diffstat (limited to 'pkg/u/file.go')
-rw-r--r-- | pkg/u/file.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/u/file.go b/pkg/u/file.go new file mode 100644 index 0000000..cf86c75 --- /dev/null +++ b/pkg/u/file.go @@ -0,0 +1,21 @@ +package u + +import ( + "errors" + "log/slog" + "os" +) + +func FileExist(filename string) bool { + if _, err := os.Stat(filename); err == nil { + return true + + } else if errors.Is(err, os.ErrNotExist) { + return false + } else { + slog.Warn("Schrödinger's file: it may or may not exist", "file", filename) + // Schrodinger: file may or may not exist. To be extra safe it will + // report the file doest not exist + return false + } +} |