github.com/jmigpin/editor@v1.6.0/util/testutil/compare.go (about) 1 package testutil 2 3 import "strings" 4 5 // Useful to compare src code lines. 6 func TrimLineSpaces(str string) string { 7 return TrimLineSpaces2(str, "") 8 } 9 10 func TrimLineSpaces2(str string, pre string) string { 11 a := strings.Split(str, "\n") 12 u := []string{} 13 for _, s := range a { 14 s = strings.TrimSpace(s) 15 if s != "" { 16 u = append(u, s) 17 } 18 } 19 return pre + strings.Join(u, "\n"+pre) 20 }