Find packages that import a package

polaris · · 445 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I was hoping to find a way to essentially reverse a package import, to find any public package that imports another package. I took a look at godoc.org figuring it might have a graph of sorts but no luck.</p> <p>The reason I want to do this is b/c I&#39;ve found a package that I&#39;d like to use but the documentation is a bit lacking. I was hoping that based on figuring out who else is using this package I can stroll through their code and learn from that instead.</p> <hr/>**评论:**<br/><br/>averagesecurityguy: <pre><p>Something like this? <a href="https://godoc.org/crypto/rand?importers" rel="nofollow">https://godoc.org/crypto/rand?importers</a></p></pre>daenney: <pre><p>Exactly that, thanks a bunch.</p> <p>How did you figure that out?</p> <p>Argh nvm, found it in the footer. Can&#39;t believe I missed that. Thanks again!</p></pre>dchapes: <pre><p>Not what you&#39;re looking for since it only looks in <code>$GOPATH</code>, but related and highly useful:</p> <pre><code>go list -f &#39;{{.ImportPath}} {{join .Imports &#34; &#34;}}&#39; ... | digraph reverse `go list` </code></pre> <p>Where digraph is <code>golang.org/x/tools/cmd/digraph</code>.</p></pre>

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

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