1、安装Sublime Text
官方地址:http://www.sublimetext.com/3
2、下载插件
打开地址Gosublime :https://github.com/DisposaBoy/GoSublime,下载zip。(我尝试git clone下载多次,都失败了,最终选择zip包)
3、自动补全功能
Perferences–Browse Packages…,进入Gosublime:
把第二部的包解压到这里,名称重命名GoSublime。
进入GoSublime目录,我的目录是C:\Users\HIGHGO\AppData\Roaming\Sublime Text 3\Packages\GoSublime
1、在src目录下创建margo目录;
2、拷贝src/margo.sh/extension-example/extension-example.go文件到margo目录下;
3、拷贝margo文件夹(所有文件和目录)到src/margo.sh/vendor目录下;
4、重新打开sublime text3
Gosublime配置
Perferences–Package Settings–Gosublime–Settings - User
{
"env": {
"GOPATH": "/data",
"GOROOT": "/usr/local/go",
"PATH": "$GOROOT:$GOPATH:$GOROOT/bin",
},
"gscomplete_enabled": true,
"fmt_enabled": true,
"fmt_tab_indent": false,
"fmt_tab_width": 4,
"autocomplete_snippets": true,
"autocomplete_tests": true,
"autocomplete_builtins": true,
"autocomplete_closures": true,
"autocomplete_suggest_imports": true,
"calltips": true,
"use_named_imports": true,
"autoinst": true,
"ipc_timeout": 1,
"fmt_cmd": ["goimports"],
"on_save": [
{"cmd": "gs_comp_lint"},
{"cmd": "goimports"}
],
"lint_enabled": true,
"linters": [
{"cmd": ["go", "run"]}
],
"comp_lint_enabled": true,
"comp_lint_commands": [
{"cmd": ["go", "install"]}
],
}
Ctrl+功能键,比如CTRL+b是内置命令行
Perferences–Package Settings–Gosublime–Key Bindings - Default
{
"keys": ["ctrl+q"],
// "keys": ["super+.", "super+h"],
"command": "gs_doc",
"args": {"mode": "hint"},
"context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }]
}
验证
输入package和fmt是否有补全功能,按下Ctrl+B是否显示命令行
参考地址:https://blog.csdn.net/CodyGuo/article/details/89199597