syntagma
syntagma

Reputation: 24304

How can I get information about type of a Go variable

Suppose I have the following code in Go:

foo, bar := someFunc(baz) 

I would like to create a Vim function to check type of foo or bar when editing a file.

Is there any tool or reliable source of information for functions from Go's packages I could use or? As for the functions declared in the file I'm editing I was thinking about simply parsing all the functions declared in that file.

Upvotes: 0

Views: 877

Answers (2)

cnicutar
cnicutar

Reputation: 182609

You are looking for something like godef

If the -t flag is given, the type of the expression will also be printed. The -a flag causes all the public members (fields and methods) of the expression, and their location, to be printed also; the -A flag prints private members too.

I know it is being used by various vim and emacs scripts.

Upvotes: 3

Dave C
Dave C

Reputation: 7878

The Go Oracle does this and much more.

vim-go is a complete vim setup for Go. It includes integration with the previously mentioned godef (as :GoDef) and Go oracle (as :GoImplements, :GoCallees, :GoReferrers, etc) as well as other tools.

Upvotes: 0

Related Questions