summaryrefslogtreecommitdiffstats
path: root/lib/str.go
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-12-20 21:00:14 -0500
committerrsiddharth <s@ricketyspace.net>2020-12-20 21:00:14 -0500
commit6a1615a635b136ec09b60ae4871056c4367832c8 (patch)
tree1f5f97ff78805a31ea2907924f538c834081b462 /lib/str.go
parente71a8f1750c2cc0fd6cbdb7048ddf5ff5ed95a7b (diff)
lib/str: add StrSplitAt
Diffstat (limited to 'lib/str.go')
-rw-r--r--lib/str.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/str.go b/lib/str.go
index 6938bfd..c93ca12 100644
--- a/lib/str.go
+++ b/lib/str.go
@@ -99,3 +99,20 @@ func NumToStr(n int64) string {
return s
}
+func StrSplitAt(c byte, s string) []string {
+ l := make([]string, 0)
+
+ acc := ""
+ for i := 0; i < len(s); i++ {
+ if s[i] == c {
+ l = append(l, acc)
+ acc = ""
+ } else {
+ acc += string(s[i])
+ }
+ }
+ if len(acc) > 0 {
+ l = append(l, acc)
+ }
+ return l
+}