This setup assumes
C:\GoPath
as your GOPATH. Changes any occurrences of this string into your GOPATH if you chose otherwise.
Setup environment variables:
-
Hit
Windows+S
, type inenvironment variables
and startEdit the system environment variables
. -
Go to the
Advanced
tab, click theEnvironment variables
(lower part of the window). -
Under
System variables
:- set
GOPATH
to valueC:\GoPath
. - modify
Path
and append the value;C:\GoPath\bin
(separate the previous path with the;
) - set
GOROOT
to valueC:\Go
.
- set
-
If you're going to use
Git Bash
, dump this in your~/.profile
(%USERPROFILE%/.profile
under Windows). Both Mac OS X and Windows should work with that configuration:
export GOPATH=/c/GoPath
export PATH=/c/GoPath/bin:$PATH
Install Sublime Text 3.
Make sure you have Package Control installed.
Install Sublime plugins:
-
Hit
Control+Shift+P
(opens the Palette) and type in:install pack
.. you should seePackage Control: Install Package
in the list. If you don't see that, installPackage Control
above. -
If
Package Control: Install Package
is shown, hit<Enter>
to pop the next box. Type inGoSublime
and hit enter. It will install GoSublime -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inGoGuru
. Hit<Enter>
again to install GoGuru. -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inGodef
. Hit<Enter>
again to install Godef. -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inSublimeLinter
. Hit<Enter>
again to install SublimeLinter 3. -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inSublimeLinter golint
. Hit<Enter>
again to install SublimeLinter-contrib-golint. -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inSublimeLinter gotype
. Hit<Enter>
again to install SublimeLinter-contrib-gotype. WARN: gotype currently blocks other linters, so you can either not install it, or disable it through theSublimeLinter
menu. -
Hit
Control+Shift+P
, type inpackage install
, hit<Enter>
and type inSublimeLinter govet
. Hit<Enter>
again to install SublimeLinter-contrib-govet.
Install some go command line tools:
- On the command line, run:
go get -u -v github.com/rogpeppe/godef
go get -u -v golang.org/x/tools/cmd/guru
go get -v golang.org/x/tools/cmd/goimports
go get -u -v github.com/golang/lint/golint
go get -u -v golang.org/x/tools/cmd/gotype
(GoCode is integrated into GoSublime.. won't use an external version)
Configuring Sublime Text 3's plugins:
- Open menu
Preferences
->Package Settings
->GoSublime
->Settings - User
and drop this in there:
{
"fmt_cmd": ["goimports"]
}
- Default bindings for GoGuru:
[{ "keys": ["ctrl+shift+g"], "command": "go_guru"}]
- Default Go to definition with GoSublime:
["keys": ["ctrl+.", "ctrl+g"], "command": "gs_doc",...}]
golint
andgotype
are enabled automatically, check the Palette underSublimeLinter
for more options. One notable function isSublimeLinter: Show all errors
.. discover the keyboard shortcut in the Palette and memorize it.
If you have any issues, please open an issue on this repo.. I want that recipe to be flawless to onboard new Go developers on Sublime.
On Mac, you might have to restart your session, so that the
~/.profile
changes are propagated to your running
session. Otherwise, try starting Sublime from a terminal which has the
GOPATH
vars set.