如何在GO中导出所有程序包API名称

export to api.txt file,such as

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

line by line

I using this to IDE autocomplete

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

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

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.