why those implementation diffrent for doPrint and doPrintln in fmt package about the spacing in between arguments.

agolangf · · 273 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>In specific my curious mind wants to know why doPrint() do not insert a space in between two args. why it is designed like this, and on the other hand doPrintln() insert spaces between two arguments.</p> <p>without looking to those implementation it was obvious to me that both will produce same output, only doPrintln will insert an extra new line at the end. But seems like those two implementation about spacing in between arguments are also different, why it is like this?</p> <p>Link : <a href="https://github.com/golang/go/blob/master/src/fmt/print.go#L1105">print.go</a></p> <hr/>**评论:**<br/><br/>f2f: <pre><p>as rob pike said in 2010:</p> <blockquote> <p>[...] Println gives you a line of text with the elements nicely spaced, while Print adds no newline and adds spaces only when non-strings would abut, as in Print(2, 3). In short, Println is for when you&#39;re lazy, Print is for when you want more control but don&#39;t want to provide special formatting.</p> </blockquote></pre>barsonme: <pre><p>Ponder: <a href="https://play.golang.org/p/8M53XKti_T" rel="nofollow">https://play.golang.org/p/8M53XKti_T</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

273 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传