Docs don't match source code?

xuanbao · · 439 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey guys I&#39;m learning go and it&#39;s very exciting! one thing that I don&#39;t understand is how time.After works. In the docs this is the definition <a href="https://golang.org/pkg/time/#example_After" rel="nofollow">https://golang.org/pkg/time/#example_After</a></p> <pre><code>func After(d Duration) &lt;-chan Time </code></pre> <p>in the actual source code, it looks like this:</p> <pre><code>func (t Time) After(u Time) bool </code></pre> <p>Why don&#39;t I see the definition that looks more like the docs with channels? Am I looking at the wrong thing?</p> <p><a href="https://github.com/golang/go/blob/master/src/time/time.go" rel="nofollow">https://github.com/golang/go/blob/master/src/time/time.go</a></p> <hr/>**评论:**<br/><br/>anossov: <pre><p>Yes, you&#39;re looking at <a href="https://golang.org/pkg/time/#Time.After" rel="nofollow">(Time) After</a></p> <p>time.After is in <a href="https://golang.org/src/time/sleep.go?s=4766:4800#L140" rel="nofollow">sleep.go</a></p> <p>You can click on the function name in the docs to go to the source.</p></pre>lems2: <pre><p>thanks! I wasn&#39;t even aware you could click on function names! they really need to make it look like a link or something</p></pre>djherbis: <pre><p>One hint that looks reliable is underline on hover.</p></pre>anossov: <pre><p>Everything that&#39;s blue is a link.</p></pre>TheMerovius: <pre><p>No, this is wrong, specifically for godoc. Looking, for example, at <a href="https://golang.org/pkg/net/http/" rel="nofollow">this</a>, the global Header isn&#39;t a link, the section headers aren&#39;t, the &#34;type/func&#34; parts of headers aren&#39;t, neither are the receiver parts of the headers.</p> <p>I agree that, personally, I never found it hard to identify links in the doc, but you shouldn&#39;t shut down someone who does by saying &#34;everything that&#39;s blue&#34;, especially if it&#39;s not even correct.</p></pre>

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

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