I am trying to generate tags for Go projects for vim. As ctags does not have native support for go I am using gotags for it. I wrote a small vim function to check if the file is .go and if so to use the gotags and not ctags:
function! g:GenerateTags()
if &filetype == 'go'
!gotags -R -f tags .
else
!ctags -R .
endif
endfunction
This works fine with other languages, but gotags just outputs to the console not to a file. I have also tried with:
system('gotags -R -f tags .')
system('gotags -R . > tags')
execute !gotags -R . > tags
But still the output is directed to the console.
Is there a way to redirect it to a file?
It seems I had a typo in the version in my vimrc as I tried again with the first version posted here and it worked:
function! g:GenerateTags()
if &filetype == 'go'
!gotags -R -f tags .
else
!ctags -R .
endif
endfunction