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