diff options
Diffstat (limited to 'pkg/util/util.go')
| -rw-r--r-- | pkg/util/util.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/util/util.go b/pkg/util/util.go index b26b46a..7963cac 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -3,6 +3,7 @@ package util import ( "iter" "math" + "strings" "time" ) @@ -162,3 +163,10 @@ func Nearest[E any](candidate E, valid []E, cmp func(E, E) int, ceil int) (E, bo } return valid[minIdx], minDistance < ceil } + +// Check if substr[left:right] is a substring of S. +// If left > len(substr) use 0 +// If right < 0 use 0 +func ContainsSliced(s, substr string, left, right int) bool { + return strings.Contains(s, substr[min(left, len(substr)):max(right, 0)]) +} |
