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
Post a Comment