From 74bcb110cba9cd22b88c561115e332d500de7716 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 1 Oct 2024 10:05:11 +0300 Subject: use of entry.Entry around the code base --- internal/oi/oi.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'internal/oi') 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 { -- cgit v1.2.3