From 783c81ae0f0f65fcc8b55df2c05207ff158f3b71 Mon Sep 17 00:00:00 2001 From: Chigozirim Igweamaka Date: Tue, 9 Jul 2024 23:10:50 +0100 Subject: [PATCH] Handle case where no match was found --- cmdHandlers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmdHandlers.go b/cmdHandlers.go index 0021edf..f125aef 100644 --- a/cmdHandlers.go +++ b/cmdHandlers.go @@ -49,6 +49,12 @@ func find(filePath string) { return } + if len(matches) == 0 { + fmt.Println("\nNo match found.") + fmt.Printf("\nSearch took: %s\n", searchDuration) + return + } + msg := "Matches:" topMatches := matches if len(matches) >= 20 {