Return error instead of nil when 'Find' fails
This commit is contained in:
@@ -148,7 +148,7 @@ func pruneIndices(indices []Match) []Match {
|
|||||||
func (regex Reg) Find(str string) (Group, error) {
|
func (regex Reg) Find(str string) (Group, error) {
|
||||||
match, err := regex.FindNthMatch(str, 1)
|
match, err := regex.FindNthMatch(str, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Group{}, nil
|
return Group{}, fmt.Errorf("no matches found")
|
||||||
}
|
}
|
||||||
return getZeroGroup(match), nil
|
return getZeroGroup(match), nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user