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。