From 6869cd00a2bb34fccb1d0c0cf45a7ba583259f30 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Fri, 31 Jan 2025 10:52:38 -0500 Subject: [PATCH] Return error instead of nil when 'Find' fails --- regex/matching.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/regex/matching.go b/regex/matching.go index fd17ea7..1951484 100644 --- a/regex/matching.go +++ b/regex/matching.go @@ -148,7 +148,7 @@ func pruneIndices(indices []Match) []Match { func (regex Reg) Find(str string) (Group, error) { match, err := regex.FindNthMatch(str, 1) if err != nil { - return Group{}, nil + return Group{}, fmt.Errorf("no matches found") } return getZeroGroup(match), nil }