英文:
How to export all package API names in GO
问题
导出到api.txt文件,例如
fmt.Println(params...)
net.LookupIP(params...)
...
逐行
我使用这个来进行IDE自动补全
英文:
export to api.txt file,such as
fmt.Println(params...)
net.LookupIP(params...)
...
line by line
I using this to IDE autocomplete
答案1
得分: 2
正如其他人所说,gocode可能已经可以满足你的需求了。但是无论如何,要列出一个包的导出API,你可以使用go tool api <pkg>
。例如:
$ go tool api runtime | grep func
pkg runtime, func Breakpoint()
pkg runtime, func CPUProfile() []byte
pkg runtime, func Caller(int) (uintptr, string, int, bool)
pkg runtime, func Callers(int, []uintptr) int
pkg runtime, func FuncForPC(uintptr) *Func
pkg runtime, func GC()
...
英文:
As others have said, gocode may well do what you want already. But anyway, to list the exported API of a package you can use go tool api <pkg>
. e.g.
$ go tool api runtime | grep func
pkg runtime, func Breakpoint()
pkg runtime, func CPUProfile() []byte
pkg runtime, func Caller(int) (uintptr, string, int, bool)
pkg runtime, func Callers(int, []uintptr) int
pkg runtime, func FuncForPC(uintptr) *Func
pkg runtime, func GC()
...
答案2
得分: 1
在go存储库中已经有一个包含完整Go1 API的文本文件:http://code.google.com/p/go/source/browse/api/go1.txt
但是我建议您设置gocode(如果还没有的话,可以通过为您的IDE编写一个小插件来实现)。它为变量和包提供上下文敏感的自动补全,即使它们不是标准库的一部分,或者它们是用不同的名称导入的。
英文:
There is already a text file with the full Go1 API in the go repository:
http://code.google.com/p/go/source/browse/api/go1.txt
But I recommend you to set up gocode (maybe by writing a small plugin for your IDE if there isn't any already). It provides context-sensitive auto-completion for variables and packages, even if they aren't part of the standard library or when they have been imported with a different name.
答案3
得分: 0
解析软件包文件,遍历顶级域名(TLDs),收集导出和公开的标识符,你就几乎达到了 gocode 多年来的水平。
英文:
Parse the package files, walk the TLDs, collect the exported and exposed identifiers, and you are almost where gocode is for years.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论