diff options
| author | Paul Buetow <paul@buetow.org> | 2024-10-01 10:05:11 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-10-01 10:05:11 +0300 |
| commit | 74bcb110cba9cd22b88c561115e332d500de7716 (patch) | |
| tree | 080287b50ff69e2e601e5ab781da500a93c4b43c /internal/oi | |
| parent | cbdce79d25206573d1f79c9c647dcaa251b69463 (diff) | |
use of entry.Entry around the code base
Diffstat (limited to 'internal/oi')
| -rw-r--r-- | internal/oi/oi.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/oi/oi.go b/internal/oi/oi.go index ca5c8c6..ea95212 100644 --- a/internal/oi/oi.go +++ b/internal/oi/oi.go @@ -8,6 +8,7 @@ import ( "path/filepath" "time" + "codeberg.org/snonux/gos/internal/entry" "golang.org/x/exp/rand" ) @@ -63,17 +64,17 @@ func ReadDirSlurp(dir string, filter func(file os.DirEntry) bool) ([]string, err return files, nil } -func ReadDirRandomEntry(dir string, filter func(file os.DirEntry) bool) (string, error) { +func ReadDirRandomEntry(dir string, filter func(file os.DirEntry) bool) (entry.Entry, error) { files, err := ReadDirSlurp(dir, filter) if err != nil { - return "", err + return entry.Zero, err } if len(files) == 0 { - return "", ErrNotFound + return entry.Zero, ErrNotFound } rand.Seed(uint64(time.Now().UnixNano())) - return files[rand.Intn(len(files))], nil + return entry.New(files[rand.Intn(len(files))]) } func IsRegular(path string) bool { |
