juntaki
1/8/2017 - 1:12 PM

GNU GLOBALでgolangの関数呼び出し行にタグジャンプする ref: http://qiita.com/juntaki/items/d52c328ab6e59f90e98b

GNU GLOBALでgolangの関数呼び出し行にタグジャンプする ref: http://qiita.com/juntaki/items/d52c328ab6e59f90e98b

     1  #include<stdio.h>
     2
     3  int a = 1;
     4
     5  int func1(){
     6    int a = 100;
     7    printf("%d", a);
     8    return 1;
     9  }
    10
    11  int main(){
    12    int a = 10;
    13    printf("%d", a);
    14    a = func1();
    15    return 0;
    16  }
 * [Specification of format version 6]
 *
 * Standard format:
 *
 *  This format is the default format of GTAGS.
 *
 *         <file id> <tag name> <line number> <line image>
 *
 *                 * Separator is single blank.
 *
 *         [example]
 *         +------------------------------------
 *         |110 func 10 int func(int a)
 *         |110 func 30 func(int a1, int a2)
 *
 *         Line image might be compressed (GTAGS_COMPRESS).
 *         Tag name might be compressed (GTAGS_COMPNAME).
 *
 * Compact format:
 *
 *  This format is the default format of GRTAGS.
 *  It is used for GTAGS with the -c option.
 *
 *         <file id> <tag name> <line number>,...
 *
 *                 * Separator is single blank.
 *
 *         [example]
 *         +------------------------------------
 *         |110 func 10,30
 *
 *         Line numbers are sorted in a line.
 *     Each line number might be expressed as difference from the previous
 *     line number except for the head (GTAGS_COMPLINE).
 *           ex: 10,3,2 means '10 13 15'.
 *     In addition,successive line numbers are expressed as a range.
 *           ex: 10-3 means '10 11 12 13'.
$ cd <target directory>
$ gogtags -v
$ ./configure --with-sqlite3
$ make
$ sudo make install
$ go get github.com/juntaki/gogtags
juntaki@ubuntu ~/g/g/test> sqlite3 -header -column GTAGS "select * from db;"
key           dat                            extra
------------  -----------------------------  ----------
 __.COMPRESS   __.COMPRESS ddefine ttypedef
 __.COMPNAME   __.COMPNAME
 __.VERSION    __.VERSION 6
func1         1 @n 5 int @n(){               1
main          1 @n 11 int @n(){              1
func1         2 @n 5 int @n(){               2
main          2 @n 11 int @n(){              2
sqlite> select * from db;
key              dat              extra
---------------  ---------------  ----------
 __.COMPACT       __.COMPACT
 __.COMPLINE      __.COMPLINE
 __.COMPNAME      __.COMPNAME
 __.VERSION       __.VERSION 6
a                1 @n 3,3-1,5-2   1
func1            1 @n 14          1
printf           1 @n 7,6         1
a                2 @n 3,3-1,5-2   2
func1            2 @n 14          2
printf           2 @n 7,6         2
juntaki@ubuntu ~/g/g/test> sqlite3 -header -column GPATH "select * from db;"
key          dat            extra
-----------  -------------  ----------
 __.VERSION   __.VERSION 2
./main.c     1
1            ./main.c
./main2.c    2
2            ./main2.c
 __.NEXTKEY  3