string.go 601 B

1234567891011121314151617181920212223
  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. }
  15. // Clone returns a copy of the string, so that we can safely point to the
  16. // copy without worrying about changes via pointers.
  17. func Clone(s string) string {
  18. stringCopy := s
  19. return stringCopy
  20. }