Spelling of sql.Result.LastInsertId

polaris · · 1913 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I was wondering, I just came across this and somehow I never noticed that ID is written as Id in this function.</p> <p><a href="https://godoc.org/database/sql#Result">https://godoc.org/database/sql#Result</a></p> <p>Is there a reason for this, or just never fixed because of backwards compatability or something?</p> <p>I&#39;m asking because go lint is pretty strict on how to write ID, URL, and terms like that :).</p> <hr/>**评论:**<br/><br/>dominikh: <pre><p>Almost all of the Go standard library predates golint, and not all of it follows the naming guidelines we abide by nowadays, as they developed over time. Id vs ID is one such case where the guidelines changed.</p> <p>Go&#39;s compatibility guarantee makes it impossible to rename that function now, so the earliest it could be changed would be Go 2.0.</p></pre>hr01: <pre><p>I know ID is the correct spelling, but I&#39;ve never understood why. Mister is Mr and not MR.</p></pre>element131: <pre><p>Because any abbreviation where you say the individual letters is supposed to be capitalized (e.g. ATM, BBC, PBS, CMS)</p></pre>danredux: <pre><p>If acronyms are all upper and shortened words are camel as usual, identification would be Id, not ID.</p></pre>i_misread_titles: <pre><p>it&#39;s an abbreviation, not an acronym (right? :) I have started lowercasing the d for all my Id fields... you could just name them Identity or Identifier. I lose my breath from holding shift through the two keystrokes... don&#39;t judge ;)</p></pre>om0tho: <pre><p>I wonder if a lot of people use golint. I thought about it for a little bit, then I read &#34;Do not treat its output as a gold standard. … In short, this tool is not, and will never be, trustworthy enough for its suggestions to be enforced automatically…&#34; from the project README.md and then I was dissuaded.</p></pre>jerf: <pre><blockquote> <p>then I was dissuaded</p> </blockquote> <p>Don&#39;t be. It&#39;s a fantastic tool for anything other than one-off code. It&#39;s just telling you that you need to use your brain, not that you can&#39;t trust it. All of my public projects are golint-clean, and it was nothing but improvement. I have some internal projects where I violate some of the rules, by choice.</p></pre>jwcrux: <pre><p>That would appear to be a bug, however I don&#39;t know when it would be fixed at this point since it would break a lot of code that already uses the function.</p></pre>SerialMiller: <pre><p>Yeah, assumed the same. Thought there might be more to it though :).</p></pre>anacrolix: <pre><p>Id is not an acronym. ID has slipped into common use. Both are correct according to the dictionary.</p></pre>

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

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