Use case question
gonzaloserrano opened this issue · 2 comments
Hi,
I'm starting with golang and i have installed gotags via https://github.com/fatih/vim-go.
I'd like to know what's the best way to generate the tags file.
My first approach has been go to $GOPATH
and from there generate recursively the tags of all its subdirectories and also the contents of $GOROOT/src
with a line like:
╭─[14:17:15] gonzalo@tribe/~/dev/sp/go
╰─○ gotags -R $GOROOT/src $GOPATH/src > tags
But if i press C-]
over the Printf
word in a line like fmt.Printf("Hello, world.\n")
what i get from the tag window within vim is a list like:
# pri kind tag file
1 F m Printf /Users/gonzalo/dev/sp/go/src/g...tools/cmd/stringer/stringer.go
access:public ctype:Generator line:173 signature:(format string, args )
173
2 F f Printf /Users/gonzalo/dev/sp/go/src/golang.org/x/tools/cmd/vet/main.go
access:public line:410 signature:(format string, args )
410
3 F f Printf /Users/gonzalo/dev/sp/go/src/g...ools/cmd/vet/testdata/print.go
access:public line:213 signature:(format string, args )
213
4 F f Printf /usr/local/Cellar/go/1.4.2/libexec/src/fmt/print.go
access:public line:196 signature:(format string, a ) type:int, error
196
5 F m Printf /usr/local/Cellar/go/1.4.2/libexec/src/log/log.go
access:public ctype:Logger line:159 signature:(format string, v )
159
6 F f Printf /usr/local/Cellar/go/1.4.2/libexec/src/log/log.go
access:public line:275 signature:(format string, v )
275
Because this Printf
function is from the fmt
package i think that somehow it should be smart enough to jump to the print.go
file from the fmt
package in the go source code, right?
Have you got to deal with this somehow?
Thanks!
That's just the way vim works with tags files, see the [vim docs for CTRL-]](http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#CTRL-]).
However, you could take a look at the vim-godef plugin. I haven't used it myself, but looking at the README I think it does what you're looking for.
Hi! Thanks for your quick response.
I just wanted to make sure my approach was correct.
I've taken a look at dgryski/vim-godef and indeed it does what i need, so thanks a lot again.