How do I get go/ast.Package.Scope.Objects to be set?

xuanbao · · 197 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>To get the ast.Package, I currently use go/build.Default.Import to get the go/build.Package, then use go/parser.ParseDir with a filter function that only allows the build.Package.GoFiles files. That all seems to work, and everything seems to get parsed, but the Objects I mentioned above is nil.</p> <p>(I need the package-level objects to get the iota count for const declarations from Object.Data.)</p> <hr/>**评论:**<br/><br/>joetsai: <pre><p>You&#39;re in luck that I was working on improving godoc and I had to deal with this problem as well.</p> <p><a href="" rel="nofollow"></a></p> <p>One way is to use ast.NewPackage with a very simple package importer.</p> <p>This is based on code found in</p></pre>MadeThisForPython: <pre><p>I&#39;d recommend you to go ask the #go-nuts channel on Freenode.</p></pre>

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

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