From e735b56a704b7328e7e84def46fd6d248c51e38d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 24 Feb 2025 21:09:14 +0200 Subject: compose mode does not require any secrets --- internal/oi/oi.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'internal/oi') 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) -- cgit v1.2.3