Go: Write carriage return with IO -


this question has answer here:

i'm trying write on file in go io.writestring, writing "\n" character not print carriage return. think maybe not carriage return need write, in windows, if open txt file wordpad, carriage return shown, not in notepad.

any ideas behaviour?, here code:

//write t := time.now().local() src, err := os.stat("/dir") if err != nil {     log.println(err, log.llongfile) } if !src.isdir() {     err = errors.new("folder not exists")     log.println(err, log.llongfile)     err = os.mkdirall("/dir", 665)     log.println(err, log.llongfile) } f, err := os.create("/dir" + "/file_" + t.format("20060102") + ".txt") n, err := io.writestring(f, "hello world\n") n, err = io.writestring(f, "goodbye\n") 

with code, result in txt file "hello worldgoodbye" if open in windows notepad.

thanks.

carriage return \r not \n.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

html - How can i make an element from a bottom stacking context stays in front of another higher stacking context? -

html - href attribute breaking an element -