summaryrefslogtreecommitdiff
path: root/internal/oi
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-24 21:09:14 +0200
committerPaul Buetow <paul@buetow.org>2025-02-24 21:09:14 +0200
commite735b56a704b7328e7e84def46fd6d248c51e38d (patch)
tree34c2bf458d6d0a136439d6891afe490eac64faa3 /internal/oi
parente957564316024f6412399015d2e8a7861e05ec82 (diff)
compose mode does not require any secrets
Diffstat (limited to 'internal/oi')
-rw-r--r--internal/oi/oi.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/internal/oi/oi.go b/internal/oi/oi.go
index 824c0bd..2f1bc1a 100644
--- a/internal/oi/oi.go
+++ b/internal/oi/oi.go
@@ -49,7 +49,22 @@ func ReadDirCh[T any](dir string, cb func(file os.DirEntry) (T, bool)) (chan T,
return ch, nil
}
-func TraverseDir(dir string, cb func(file os.DirEntry) error) error {
+func ReadDir[T any](dir string, cb func(file os.DirEntry) (T, bool)) ([]T, error) {
+ var results []T
+
+ ch, err := ReadDirCh(dir, cb)
+ if err != nil {
+ return results, err
+ }
+
+ for file := range ch {
+ results = append(results, file)
+ }
+
+ return results, nil
+}
+
+func ForeachDirEntry(dir string, cb func(file os.DirEntry) error) error {
if err := EnsureDir(dir); err != nil {
return err
}
@@ -69,21 +84,6 @@ func TraverseDir(dir string, cb func(file os.DirEntry) error) error {
return errors.Join(errs...)
}
-func ReadDir[T any](dir string, cb func(file os.DirEntry) (T, bool)) ([]T, error) {
- var results []T
-
- ch, err := ReadDirCh(dir, cb)
- if err != nil {
- return results, err
- }
-
- for file := range ch {
- results = append(results, file)
- }
-
- return results, nil
-}
-
func ReadDirRandom[T any](dir string, cb func(file os.DirEntry) (T, bool)) (T, error) {
results, err := ReadDir(dir, cb)