string.go 405 B

12345678910111213141516
  1. package string
  2. import (
  3. "strings"
  4. )
  5. // TrimSplit slices s into all substrings separated by sep and returns a
  6. // slice of the substrings between the separator with all leading and trailing
  7. // white space removed, as defined by Unicode.
  8. func TrimSplit(s, sep string) []string {
  9. trimmed := strings.Split(s, sep)
  10. for i := range trimmed {
  11. trimmed[i] = strings.TrimSpace(trimmed[i])
  12. }
  13. return trimmed
  14. }