在Sublime Text2中开发Golang

Sublime Text 2 是一个可定制程度相当高的轻量级编辑器,具有丰富的第三方插件,关键是可以无限期的免费使用。下面就介绍通过安装几种插件,将Sublime Text 2定制成为一款相当好用的Golang IDE。
下载
- 下载Sublime Text 2
- 安装
安装Package Control
- 按Ctrl + ` 打开console
- 粘贴下列代码到console并回车 重启Sublime Text 2, 重启后,如果在 Preferences菜单下,多出一个菜单项 Package Control,说明安装成功。
1
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
安装 gocode
打开终端,输入以下内容(需要安装git工具):
1 | go get github.com/nsf/gocode |
安装完成后,我们可以在 go/bin 目录下,发现多出了个 gocode 文件。
安装 Gosublime 插件
- Ctrl+Shift+p 打开Package Controll 输入pcip(即“Package Control: Install Package”的缩写)
- 输入GoSublime,回车开始安装
安装 SidebarEnhancements 插件
- Ctrl+Shift+p 打开Package Controll 输入pcip
- 输入SidebarEnhancements,回车开始安装
安装 Go Build 插件
安装
- Ctrl+Shift+p 打开Package Controll 输入pcip
- 输入 Go Build ,回车开始安装
如果通过Package Controll 不能安装 Go Build, 那么可以通过git手动安装:
For Windows:
Open a cmd, go to%APPDATA%\Sublime Text 2\Packages
and type…For Linux:
Open a shell, go to~/.config/Sublime Text 2/Packages
and type…git clone git://github.com/cthackers/SublimeGoBuild.git
使用
F5
to run your projectF7
to buildCTRL + F5
to run tests
安装 Git Gutter 插件
Git Gutter is a sublime text 2/3 plugin to show an icon in the gutter area indicating whether a line has been inserted, modified or deleted.
- Ctrl+Shift+p 打开Package Controll 输入pcip
- 输入 Git Gutter,回车开始安装
安装 SideBarGit 插件
SideBarGit provides git commands on Side Bar of Files and Folders for Sublime Text 2.
- Ctrl+Shift+p 打开Package Controll 输入pcip
- 输入 SideBarGit,回车开始安装
- 标题: 在Sublime Text2中开发Golang
- 作者: zjun
- 创建于 : 2014-01-16 21:06:19
- 更新于 : 2023-11-30 15:37:14
- 链接: https://zjun.site/2014/01/759bcd250fb1.html
- 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论