snippetgoCritical
How to strings.Split on newline?
Viewed 0 times
howsplitnewlinestrings
Problem
I'm trying to do the rather simple task of splitting a string by newlines.
This does not work:
Any ideas?
This does not work:
temp := strings.Split(result, `\n`)Any ideas?
Solution
You have to use
Splitting on `
playground
"\n".Splitting on `
\n, searches for an actual \ followed by n` in the text, not the newline byte.playground
Context
Stack Overflow Q#25080862, score: 122
Revisions (0)
No revisions yet.