How do I remove all Unicode newlines from a UTF-8 string in GoLang? I found this answer for PHP.
Asked
Active
Viewed 3,719 times
1 Answers
5
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)
}

OneOfOne
- 95,033
- 20
- 184
- 185