Reformatted error messages according to Go guidelines

master
Aadhavan Srinivasan 6 days ago
parent d44a25f412
commit 5e3801af7c

@ -176,7 +176,7 @@ func FindNthMatch(regex Reg, str string, n int) (Match, error) {
} }
} }
// We haven't found the nth match after scanning the string - Return an error // We haven't found the nth match after scanning the string - Return an error
return nil, fmt.Errorf("Invalid match index. Too few matches found.") return nil, fmt.Errorf("invalid match index - too few matches found")
} }
// FindAllMatches tries to find all matches of the regex represented by given start-state, with // FindAllMatches tries to find all matches of the regex represented by given start-state, with

@ -5,7 +5,7 @@ import "errors"
// Helper functions for slices, to make them behave more like stacks // Helper functions for slices, to make them behave more like stacks
func peek[T any](s []T) (T, error) { func peek[T any](s []T) (T, error) {
if len(s) < 1 { if len(s) < 1 {
return *new(T), errors.New("Stack empty") return *new(T), errors.New("stack empty")
} }
return s[len(s)-1], nil return s[len(s)-1], nil
} }
@ -20,7 +20,7 @@ func mustPop[T any](sp *[]T) T {
func pop[T any](sp *[]T) (T, error) { func pop[T any](sp *[]T) (T, error) {
if len(*sp) < 1 { if len(*sp) < 1 {
return *new(T), errors.New("Stack empty") return *new(T), errors.New("stack empty")
} }
to_return := (*sp)[len(*sp)-1] to_return := (*sp)[len(*sp)-1]
*sp = (*sp)[:len(*sp)-1] *sp = (*sp)[:len(*sp)-1]

Loading…
Cancel
Save