<p>After a couple of months of on-off Go development, I wonder if I maybe miss something obvious about the Go package documentation.</p>
<p>Say I want to decode a JSON file. The documentation tells me that there is <code>encoding/json.NewDecoder(r io.Reader)</code>. The documentation for <code>io.Reader</code> has no hints about known implementations. Likewise, <code>os.File</code> does not mention that it implements <code>io.Reader</code>. So how, short of reading the interface in its entirety and manually compare it with the functions documented for <code>os.File</code> or just try it and see if the compile blows up, am I supposed to know that I can use a file handle for the JSON decoder? (For that matter, can I? I really can't remember right now :P)</p>
<p>I suppose checking every type against every interface is not feasable for <code>go doc</code>. ;-)</p>
<hr/>**评论:**<br/><br/>cougarpoop: <pre><p>Use the type analyzer of godoc: <a href="https://golang.org/lib/godoc/analysis/help.html">https://golang.org/lib/godoc/analysis/help.html</a></p></pre>mwholt: <pre><p>I did not know about this
![](https://static.golangjob.cn/static/img/banner.png)