summaryrefslogtreecommitdiff
path: root/internal/oi
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-09-28 12:08:58 +0300
committerPaul Buetow <paul@buetow.org>2024-09-28 12:08:58 +0300
commitc76ba11dc4ae23ab17115b87d0d2b9711ffdbf01 (patch)
tree86f33c1b22d0fc4be27357cc5f68006bfa8b321a /internal/oi
parent076c0d5afb299fedc5ee61a13bfec7f86055fc89 (diff)
fix this
Diffstat (limited to 'internal/oi')
-rw-r--r--internal/oi/oi.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/oi/oi.go b/internal/oi/oi.go
index 27112bf..ca5c8c6 100644
--- a/internal/oi/oi.go
+++ b/internal/oi/oi.go
@@ -11,6 +11,8 @@ import (
"golang.org/x/exp/rand"
)
+var ErrNotFound = errors.New("no file/entry found")
+
func EnsureDirExists(dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
return os.MkdirAll(dir, os.ModePerm)
@@ -67,7 +69,7 @@ func ReadDirRandomEntry(dir string, filter func(file os.DirEntry) bool) (string,
return "", err
}
if len(files) == 0 {
- return "", errors.New("no entry/file found")
+ return "", ErrNotFound
}
rand.Seed(uint64(time.Now().UnixNano()))