Goguru是用于集成Go Guru工具的Sublimetext 3的Golang插件。
请在此处报告任何问题或改进
根据Waigani的先前工作。
Guru工具仍在开发中,查看计划,官方GIT回购和代码审查,如果您想跟上:
选择或放置光标,将符号(功能,变量,常数等),然后按ctrl+shift+g 。将向您提供以下分析方式供您选择:
callees show possible targets of selected function call
callers show possible callers of selected function
callstack show path from callgraph root to selected function
definition show declaration of selected identifier
describe describe selected syntax: definition, methods, etc
freevars show free variables of selection
implements show 'implements' relation for selected type or method
peers show send/receive corresponding to selected channel op
pointsto show variables the selected pointer may point to
referrers show all refs to entity denoted by selected identifier
what show basic information about the selected syntax node
whicherrs show possible values of the selected error variable
选择其中一种模式,输出将显示在新选项卡中。双击结果中的文件名直接跳到它。
您还可以将ctrl键并right-click符号,以直接跳到定义。
从http://wbond.net/sublime_packages/package_control安装Sublime软件包控件(如果还没有这样做)。确保重新启动ST以完成安装。
提出命令调色板(默认CTRL+SHIFT+P或CMD+SHIFT+P),然后开始键入软件包控制:安装程序包,然后按返回或单击该选项以激活它。将向您提供一个新的快速面板,其中包含可用软件包的列表。键入Goguru,然后按返回或进入其输入以安装Goguru。如果没有Goguru的条目,您很可能已经安装了它。
Goguru有几个要设置的变量才能工作。这些在默认设置首选项的Preferences > Package Settings > GoGuru > Settings-Default中说明了这些内容:
{
// use golangconfig, if false then shellenv will be used to get golang environment variables
"goguru_use_golangconfig" : false ,
// adds to the guru_scope the current package of the the working file
"goguru_use_current_package" : true ,
// besides showing the result, jump directly to the definition
"goguru_jumpto_definition" : false ,
// The output can either be one of: 'buffer', 'output_panel'
// Buffers can hold results from more than one invocation
// Output panels sit underneath the editor area and are easily dismissed
"goguru_output" : "output_panel" ,
// print debug info to the terminal
"goguru_debug" : false ,
// Set guru's output to json
"goguru_json" : false ,
// an array of scopes of analysis for guru.
// e.g (for github.com/juju/juju) "guru_scope": ["github.com/juju/juju/cmd/juju", "github.com/juju/juju/cmd/jujud"]
"goguru_scope" : [ ] ,
// an array of build tags of analyzed source files
"goguru_tags" : [ ] ,
// env overwrites the default shell environment vars
// e.g "env": { "GOPATH": "$HOME/go/bin:$PATH" }
// not used when goguru_use_golangconfig is set to true
"goguru_env" : { } ,
}您将自己的变量设置在Preferences > Package Settings > GoGuru > Settings-User中。
您还可以进行特定项目设置。首先将您当前的工作区作为项目Project > Save as project ... ,然后编辑您的项目Project > Edit Project 。以下是一个示例,该示例设置了goguru,可在github.com/juju/juju codebase上使用:
{
"folders" :
[
{
"follow_symlinks" : true ,
"path" : "/home/user/go/src/github.com/juju/juju"
}
] ,
"settings" :
{
"GoGuru" : {
"goguru_scope" : [ "github.com/juju/juju/cmd/juju" , "github.com/juju/juju/cmd/jujud" ] ,
"goguru_output" : "output_panel"
}
} ,
}默认键绑定:
[
{ "keys" : [ "ctrl+shift+g" ] , "command" : "go_guru" } ,
{ "keys" : [ "ctrl+alt+shift+g" ] , "command" : "go_guru_show_results" } ,
{ "keys" : [ "ctrl+.+ctrl+g" ] , "command" : "go_guru_goto_definition" , "context" : [ { "key" : "selector" , "operator" : "equal" , "operand" : "source.go" } ] } ,
]您可以通过将以上内容复制到Preferences > Keybindings - User并用您的首选密钥(S)替换CTRL+Shift+G来设置自己的键绑定。
您还可以通过添加“模式” arg,例如:
...
{ "keys" : [ "ctrl+super+c" ] , "command" : "go_guru" , "args" : { "mode" : "callers" } } ,
{ "keys" : [ "ctrl+super+i" ] , "command" : "go_guru" , "args" : { "mode" : "implements" } } ,
{ "keys" : [ "ctrl+super+r" ] , "command" : "go_guru" , "args" : { "mode" : "referrers" } } ,
{ "keys" : [ "ctrl+.+ctrl+g" ] , "command" : "go_guru" , "args" : { "mode" : "definition" , output = false } } ,
...默认鼠标绑定:
[
{
"button" : "button2" ,
"modifiers" : [ "ctrl" ] ,
"press_command" : "drag_select" ,
"command" : "go_guru" ,
"args" : {
"mode" : "definition" ,
"output" : false
} ,
} ,
] Goguru依靠Guru工具。您必须安装它才能使Goguru工作。在命令行上运行以下内容:
go install golang.org/x/tools/cmd/guru@latest
go get -u golang.org/x/tools/cmd/guru
Goguru根据MIT许可发布。请参阅许可证
Goguru是Goguru作者的版权所有的作品,即Alvarolm和所有贡献者。如果您提交更改,无论是文档还是代码,只要它致力于Goguru的历史记录,我就会认为您是贡献者。有关所有Goguru作者/贡献者的列表,请参见Author.md。