From b37b535dc72835c96b89ca667a8c506daf75ed44 Mon Sep 17 00:00:00 2001 From: fcd Date: Sat, 15 Jul 2023 17:15:44 +0300 Subject: [PATCH] feat: return empty list if dir not exists when using readdir --- selection/selection.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selection/selection.go b/selection/selection.go index 845e80a..57d249e 100644 --- a/selection/selection.go +++ b/selection/selection.go @@ -136,7 +136,9 @@ func readdir(target string, settings entity.ActionSettings) ([]entity.Entry, err var out []entity.Entry target = mare.ExpandUser(target) entries, err := os.ReadDir(target) - if err != nil { + if os.IsNotExist(err) { + return out, nil + } else if err != nil { return out, fmt.Errorf("error reading contents of directory %s: %v", target, err) }