diff options
author | rsiddharth <s@ricketyspace.net> | 2021-01-30 14:01:08 -0500 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2021-01-30 14:01:08 -0500 |
commit | b28d86d2778a29f1ebd9f5a678653b4b62ebcb4b (patch) | |
tree | 7ccceae6a304840e00e14aa5a3712ad116425e77 | |
parent | d1e448cfa5a2c87de9a22f8717478a9c54bdda99 (diff) |
lib: add StrHas
-rw-r--r-- | lib/str.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 +} |