如何用回车符打印字符串

问题描述:

I have a string which ends with a carriage return:

        str := "my data"

If I try to print that string, using:

        fmt.Println(str)

all it shows is an empty line. How do I make it output full string, like "my data", without trimming the last character (carriage return)?

我有一个以回车符结尾的字符串: p>

  str:=”我的数据
“ 
  code>  pre> 
 
 

如果我尝试打印该字符串,请使用: p >

  fmt.Println(str)
  code>  pre> 
 
 

所有显示为空 线。 p> div>如何在不修剪最后一个字符(回车)的情况下输出完整的字符串(如“我的数据”)? p> div>

It was caused by Emacs terminal, which discarded data printed before carriage return.

Using gnome-terminal fixed it. Thanks for your help @peter