从 https://gist.github.com/bopjiang/11146574 下载, 做了修改。
cscope-go.sh
#!/bin/bash # generate cscope index files in current directory
# the generated cscope index files also include go standard packages if [ "$GOROOT" = "" ] ; then
echo "GOROOT is not set"
GOROOT=`go env |grep "GOROOT" |cut -d "=" -f2`
GOROOT=${GOROOT#\"}
GOROOT=${GOROOT%\"}
fi
echo $GOROOT go_pkg_src=$GOROOT/pkg find $go_pkg_src -name "*.go" -print > cscope.files
find . -name "*.go" -print >> cscope.files if cscope -b -k; then
echo "Done"
else
echo "Failed"
exit
fi
也可以使用starscope
$ sudo apt-get install ruby-dev
$ sudo gem install starscope therubyracer execjs
$ cd ~/my-project
$ starscope
```
Ask it things directly:
```
$ starscope -q calls,new # Lists all callers of new
```
Export it to various existing formats for automatic integration with your editor:
```
$ starscope -e ctags
$ starscope -e cscope