go - Golang - Removing all Unicode newline characters from a string -


how remove unicode newlines utf-8 string in golang? found this answer php.

you can use strings.map:

func filternewlines(s string) string {     return strings.map(func(r rune) rune {         switch r {         case 0x000a, 0x000b, 0x000c, 0x000d, 0x0085, 0x2028, 0x2029:             return -1         default:             return r         }     }, s) } 

playground


Comments