Dante
Dante

Reputation: 11264

How to get type info from Go compiled packages in language x?

I want to write a simple editor with basic autocomplete functionality for the Go language as a pet project. How would one go about doing it? I took a look at the Go plugins for Eclipse and IntelliJ, but they were too big for me to comprehend (not to mention getting one to compile).

Upvotes: 2

Views: 180

Answers (2)

zzzz
zzzz

Reputation: 91203

The de facto standard approach to this problem is to use nsf's gocode. I have tried it only in Vim - it works very well.

Even though there's ready made support for specific editors, gocode is not editor specific. It's a daemon with a communication protocol. It is thus usable from any program.

Upvotes: 2

nemo
nemo

Reputation: 57609

The Go standard library offers the building blocks for a Go parser which you can use to parse the source files and look for function definitions and the like.

There's also the godoc command which already does what you want: extracting method definitions and it's documentation. You may look in the source code to see how godoc is working or use godoc directly.

This editor written in Go projects has a manageable amount of code, you may look into it.

Upvotes: 2

Related Questions