parsers/utils.go

23 lines
408 B
Go
Raw Permalink Normal View History

2022-08-04 00:05:19 +02:00
package parsers
import (
"strconv"
"strings"
)
2022-08-04 00:05:19 +02:00
func atoi(s string) (int, bool) {
v, err := strconv.Atoi(s)
if err != nil {
return 0, false
}
return v, true
}
func TrimPrefixSuffix(arr []string, prefix, suffix string) []string {
trims := make([]string, 0, len(arr))
for _, str := range arr {
trims = append(trims, strings.TrimSuffix(strings.TrimPrefix(str, prefix), suffix))
}
return trims
}