diff options
Diffstat (limited to 'pkg/u')
-rw-r--r-- | pkg/u/file.go | 21 | ||||
-rw-r--r-- | pkg/u/list.go (renamed from pkg/u/util.go) | 0 | ||||
-rw-r--r-- | pkg/u/list_test.go (renamed from pkg/u/util_test.go) | 0 |
3 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 + } +} diff --git a/pkg/u/util.go b/pkg/u/list.go index 34eafd1..34eafd1 100644 --- a/pkg/u/util.go +++ b/pkg/u/list.go diff --git a/pkg/u/util_test.go b/pkg/u/list_test.go index a6d84c7..a6d84c7 100644 --- a/pkg/u/util_test.go +++ b/pkg/u/list_test.go |