user1391070
user1391070

Reputation: 53

How to export all package API names in GO

export to api.txt file,such as

fmt.Println(params...)
net.LookupIP(params...)
...

line by line

I using this to IDE autocomplete

Upvotes: 1

Views: 497

Answers (3)

axw
axw

Reputation: 7083

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()
...

Upvotes: 2

tux21b
tux21b

Reputation: 94799

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.

Upvotes: 1

zzzz
zzzz

Reputation: 91409

Parse the package files, walk the TLDs, collect the exported and exposed identifiers, and you are almost where gocode is for years.

Upvotes: 0

Related Questions