summaryrefslogtreecommitdiff
path: root/internal/oi
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-31 23:09:54 +0200
committerPaul Buetow <paul@buetow.org>2024-10-31 23:09:54 +0200
commitc2b3c4f6e4d40c49d55deb5b696bb3cb8cdde531 (patch)
tree1f83f75bf085dc1b02e7562cfcb759f4d8c6486c /internal/oi
parent1c143f2e4faeb803f5f7c96f29c1ef447a0b2097 (diff)
intial warning when there aren't enough queued
Diffstat (limited to 'internal/oi')
-rw-r--r--internal/oi/oi.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/oi/oi.go b/internal/oi/oi.go
index b2a0953..2aa4417 100644
--- a/internal/oi/oi.go
+++ b/internal/oi/oi.go
@@ -84,20 +84,20 @@ func ReadDir[T any](dir string, cb func(file os.DirEntry) (T, bool)) ([]T, error
return results, nil
}
-func ReadDirRandom[T any](dir string, cb func(file os.DirEntry) (T, bool)) (T, error) {
+func ReadDirRandom[T any](dir string, cb func(file os.DirEntry) (T, bool)) (T, int, error) {
results, err := ReadDir(dir, cb)
if err != nil {
var zero T
- return zero, err
+ return zero, 0, err
}
if len(results) == 0 {
var zero T
- return zero, ErrNotFound
+ return zero, 0, ErrNotFound
}
rand.Seed(uint64(time.Now().UnixNano()))
- return results[rand.Intn(len(results))], nil
+ return results[rand.Intn(len(results))], len(results), nil
}
func IsRegular(path string) bool {