summaryrefslogtreecommitdiffstats
path: root/lib/str.go
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2021-01-30 14:01:08 -0500
committerrsiddharth <s@ricketyspace.net>2021-01-30 14:01:08 -0500
commitb28d86d2778a29f1ebd9f5a678653b4b62ebcb4b (patch)
tree7ccceae6a304840e00e14aa5a3712ad116425e77 /lib/str.go
parentd1e448cfa5a2c87de9a22f8717478a9c54bdda99 (diff)
lib: add StrHas
Diffstat (limited to 'lib/str.go')
-rw-r--r--lib/str.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/str.go b/lib/str.go
index bc25e2d..8211ea8 100644
--- a/lib/str.go
+++ b/lib/str.go
@@ -131,3 +131,13 @@ func StrToUpper(s string) string {
}
return us
}
+
+// Returns true if string 's' has string 'n' in it.
+func StrHas(s, n string) bool {
+ for i := 0; i < len(s); i++ {
+ if s[i:i+len(n)] == n {
+ return true
+ }
+ }
+ return false
+}