|
|
|
@ -21,7 +21,7 @@ func SplitBy(input, delim string) (string, string) {
|
|
|
|
|
return input[:index], input[index+len(delim):]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SplitBy takes an input string and a delimiter, returning resulting two string from split with the delim at beginning of 2nd
|
|
|
|
|
// SplitByBefore takes an input string and a delimiter, returning resulting two string from split with the delim at beginning of 2nd
|
|
|
|
|
func SplitByBefore(input, delim string) (string, string) {
|
|
|
|
|
index := strings.Index(input, delim)
|
|
|
|
|
if index == -1 {
|
|
|
|
@ -38,3 +38,17 @@ func SplitByLast(input, delim string) (string, string) {
|
|
|
|
|
}
|
|
|
|
|
return input[:index], input[index+len(delim):]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FileExt returns the file extension of a file with a supplied path, doesn't include '.'
|
|
|
|
|
func FileExt(path string) string {
|
|
|
|
|
i := len(path) - 1
|
|
|
|
|
for ; i >= 0; i-- {
|
|
|
|
|
switch path[i] {
|
|
|
|
|
case '/':
|
|
|
|
|
return ""
|
|
|
|
|
case '.':
|
|
|
|
|
return path[i+1:]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|