gitlab.com/evatix-go/core@v1.3.55/coredata/stringslice/NonWhitespaceTrimSlice.go (about) 1 package stringslice 2 3 import ( 4 "strings" 5 ) 6 7 func NonWhitespaceTrimSlice(slice []string) []string { 8 if slice == nil { 9 return []string{} 10 } 11 12 length := len(slice) 13 14 if length == 0 { 15 return []string{} 16 } 17 18 newSlice := MakeDefault(length) 19 20 for _, s := range slice { 21 trimmed := strings.TrimSpace(s) 22 if len(trimmed) == 0 { 23 continue 24 } 25 26 newSlice = append(newSlice, trimmed) 27 } 28 29 return newSlice 30 }