How to write a few lines to a file? For some reason, all functions ignore '\ n'. For example:

package main import ( "os" ) func main() { file, _ := os.Create("A.txt") file.WriteString("AAA\nBBB") } 

This code is written to the A.txt file AAABBB .

  • Are you on Windows? - Ainar-G
  • @ Ainar-g on windows. - Ca6aqa
  • Well so at you \r\n it is necessary to do. - Ainar-G
  • @ Ainar-G Thank you. - Ca6aqa

1 answer 1

On Windows, in contrast to Unix-like systems, the combination of CR-LF is used to translate a string, it is also \r\n . See table .