aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/util/util.go
diff options
context:
space:
mode:
authorJP Appel <jeanpierre.appel01@gmail.com>2025-08-10 04:04:41 -0400
committerJP Appel <jeanpierre.appel01@gmail.com>2025-08-10 04:04:41 -0400
commit92de2b63b6bd0642b92e7ca1c6110bab7f3a2e6b (patch)
treee32f3759413e992fa2fcd01c7f254c17d4bf8eed /pkg/util/util.go
parent5d0b36cf87ee94c690d11c0beab48f4dadc6fc52 (diff)
Change approximate statmenets to use sqlite MATCH operator
Diffstat (limited to 'pkg/util/util.go')
-rw-r--r--pkg/util/util.go8
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)])
+}