From b28d86d2778a29f1ebd9f5a678653b4b62ebcb4b Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 30 Jan 2021 14:01:08 -0500 Subject: lib: add StrHas --- lib/str.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/str.go') 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 +} -- cgit v1.2.3