From 574e76ae935c4931ec50b14a94dee930ed6f3d5a Mon Sep 17 00:00:00 2001 From: ayyansea Date: Mon, 18 Nov 2024 21:53:29 +0300 Subject: feat: restructure project + add a basic cli arg parser --- util/split/split.go | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 util/split/split.go (limited to 'util/split') diff --git a/util/split/split.go b/util/split/split.go deleted file mode 100644 index 2fc29db..0000000 --- a/util/split/split.go +++ /dev/null @@ -1,45 +0,0 @@ -package split - -import ( - "strings" -) - -func checkArrayElementsEmpty(array []string) bool { - for _, str := range array { - if str != "" { - return false - } - } - return true -} - -func NewArrayWithSplit(initialArray []string, index int, token string, delimeter string) (result []string) { - split := strings.Split(token, delimeter) - splitLength := len(split) - - /* - When a token only consists of delimeter * N (N >= 0), - the resulting split consists of N empty elements. - Here we check if it is so and essentialy remove that token - from resulting array. - */ - - splitIsEmpty := checkArrayElementsEmpty(split) - if splitIsEmpty { - result = append(initialArray[:index], initialArray[index+1:]...) - return result - } - - if splitLength > 1 { - if split[splitLength-1] == "" { - split = split[:splitLength-1] - } - - result = append(initialArray[:index], append(split, initialArray[index+1:]...)...) - } - if splitLength == 1 { - result = initialArray - } - - return result -} -- cgit v1.2.3