Carefully formatted raw usage string

xuanbao · · 301 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>How can you write a carefully formatted raw usage string that will not be reformatted by gofmt and still be valid syntax? Think left-aligned, multiline raw string in a function named print_help(). I&#39;ve been doing this in all other languages I&#39;ve used and you can not and don&#39;t want to always rely on the generated usage string of a getopts equivalent.</p> <hr/>**评论:**<br/><br/>epiris: <pre><p>I don&#39;t understand what your saying entirely? But if you mean multi line string literals:</p> <pre><code>var foo = {back tick doesn&#39;t exist on iPhone what the fuck} My String {end back tick} </code></pre></pre>sh41: <pre><p>Backtick exists on iOS, you have to get to it by holding down &#39; key, it&#39;ll be one of the alternative similar keys presented.</p></pre>epiris: <pre><p>Wowwwwwwwwwww</p> <p>I just discovered the other insane UX issue I had with cursor movement highlighting entire words it thought was misspelled and general cursor control is fixed by holding down any letter.. which is more useful than typing backticks. Which apparently I can&#39;t do or am some sort of idiot. Fairly new to iPhone though. Whatever. Lol. Thanks man :-)</p></pre>danredux: <pre><p>here have mine `</p></pre>danredux: <pre><p>sry you needed another one here `</p></pre>epiris: <pre><p>Lol</p></pre>sh41: <pre><p>gofmt doesn&#39;t modify the contents of raw strings.</p></pre>carstenm: <pre><p>It did in a function like</p> <pre><code>func print_help() { fmt.Println( `first line more lines more lines last line`) } </code></pre> <p>Left-alignment is the whole purpose of formatting it in a function call or const string definition like that.</p></pre>barsonme: <pre><p>You mean like this? <a href="https://play.golang.org/p/0M80MQLHAm" rel="nofollow">https://play.golang.org/p/0M80MQLHAm</a></p> <p>It doesn&#39;t affect anything.</p></pre>carstenm: <pre><p>Except the first line, but I guess I can live with this quirk/limitation. This is a case where a comment to have gofmt ignore a function would be useful, but that would contradict gofmt&#39;s design.</p></pre>barsonme: <pre><p>Ah. So it&#39;s the appearance that bothers you? Gotcha. I was saying the output is gonna be the same. </p></pre>

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

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