str.go 334 B

12345678910111213141516171819
  1. package util
  2. import "strings"
  3. func TrimHtml(data string) string {
  4. nlist := strings.Split(data, "\n")
  5. res := []string{}
  6. for _, item := range nlist {
  7. item = strings.Trim(item, " ")
  8. if item == "" {
  9. continue
  10. } else if item == "\r" {
  11. continue
  12. } else {
  13. res = append(res, item)
  14. }
  15. }
  16. return strings.Join(res, "\n")
  17. }