Is the below code expected behaviour with strings.SplitAfter?
I would expect (and think it more helpful) if it returned just the 2 slice elements?
Sorry if a dumb simple question but I couldn’t seem to find a similar question or definitive answer
SplitAfter slices s into all substrings after each instance of sep and returns a slice of those substrings.
So from that snippet, I’d expect a slice with line0 and line1, both ending with a newline and also a third empty string, as that is what comes after the second newline in the original string.
Thanks guys, I see that help snippet can be interpreted that way even if there aren’t any strings after the separator to become a substring. Will bear in mind adjusting to the off by 1s which GO is usually quite friendly to avoid or try something like in your suggestion. Cheers