Go的ctag数据库 [英] ctag database for Go

查看:130
本文介绍了Go的ctag数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Go源生成标签文件在Mac中,我安装了旺盛的ctags,并在源目录中尝试了以下命令:

  ctags -f gosource.tags -R`pwd` 

但是,它不考虑* .go文件。我必须使用-h选项吗?但是,是不是只为头文件,按照手册?



请给我正确的命令,以便我可以在vim中使用标签文件。我也更喜欢绝对路径,以便我可以随时保存文件。



谢谢。

编辑:
我假设当前ctags支持Go,请参阅 http://groups.google .com / group / golang-nuts / browse_thread / thread / 3a4848db231b02c9

但是, http://ctags.sourceforge.net/languages.html 不会被列出。

解决方案

将以下内容添加至〜/ .ctags

   -  langdef = Go 
--langmap = Go:.go
--regex -Go = / func([\t] + \([^)] + \))?[\t] +([ a-zA-Z0-9 _] +)/ \ 2 / d,func /
--regex -Go = / var [\t] +([a-zA-Z _] [a-zA- Z0-9 _] +)/ \ 1 / d,var /
--regex-Go = / type [\t] +([a-zA-Z _] [a-zA-Z0-9_] +)/ \ 1 / d,类型/

(From http://go-wise.blogspot.com/2011/09/using-ctags-with-go.html a>)


How to generate tags file for Go source

In mac, I installed exuberant ctags , and tried the below command in source directory

ctags -f gosource.tags -R `pwd`

But, it doesn't consider *.go files. Do I have to use -h option? But, isn't it only for header files, as per the manual?

Please give me the correct command so that I can use the tags file with vim. I also prefer absolute path so that I can keep the file anywhere

Thanks.

Edit: I assumed current ctags support Go, seeing http://groups.google.com/group/golang-nuts/browse_thread/thread/3a4848db231b02c9.

but, http://ctags.sourceforge.net/languages.html desn't have go listed.

解决方案

Add the following to ~/.ctags

--langdef=Go
--langmap=Go:.go
--regex-Go=/func([ \t]+\([^)]+\))?[ \t]+([a-zA-Z0-9_]+)/\2/d,func/
--regex-Go=/var[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,var/
--regex-Go=/type[ \t]+([a-zA-Z_][a-zA-Z0-9_]+)/\1/d,type/

(From http://go-wise.blogspot.com/2011/09/using-ctags-with-go.html)

这篇关于Go的ctag数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆