Hidden Maze CRLF

A newline that kills time if you don’t know.

system-specific newline

Windows Linux macOS
CRLF LF LF
\r\n \n \n

Note Classic Mac OS uses CR (\r)

Case

Split newline

Windows development Linux distribution. Problems were not found during development, but found after deployment. Even if you know what you know, it is difficult to find it if you don’t pay attention in advance.

{{ $dst := (split $src "\n") }}

How to handle

Replace CR, Split LF processing

{{ $dst := (split (replace $src "\r" "") "\n") }}

Continue! 👍