Supercharge your sublime text for #golang development

$ go get -u github.com/nsf/gocode
$ go get -u golang.org/x/tools/cmd/guru
$ go get -u golang.org/x/tools/cmd/goimports
$ go get -u golang.org/x/tools/cmd/gorename
$ go get -u github.com/golang/lint/golint
$ go get -u github.com/jgautheron/goconst/cmd/goconst
$ go get -u github.com/jgautheron/usedexports
$ go get -u github.com/gordonklaus/ineffassign

Pay attention to the gutter and status bar when you save your code. This is how your linters communicate with you.

{
"env": {
"GOPATH": "/home/arsham/Projects/Go:/usr/bin/go",
"PATH": "/home/arsham/Projects/Go/bin:$PATH:/usr/bin",
},
"comp_lint_enabled": true,
"ipc_timeout": 2,
"fmt_cmd": ["goimports", "-srcdir", "$_dir"],
"on_save": [
{"cmd": "gs_comp_lint"},
],
"comp_lint_commands": [
{"cmd": ["go", "build", "-i"]},
{"cmd": ["golint $_fn"], "shell": true},
{"cmd": ["go", "vet"]},
{"cmd": ["goconst $_dir"], "shell": true},
{"cmd": ["usedexports $_dir"], "shell": true},
{"cmd": ["ineffassign $_fn"], "shell": true},
],
}

Please note that we are replacing gofmt with goimports here. The first comp_lint_command command (go build -i) makes sure the completion works.

ctrl+., ctrl+a: Browse all declarations.
ctrl+., ctrl+p: Manipulate import secion without having to go there.
ctrl+., ctrl+e: Show linter issues.

GoTo Definition

{ "keys": ["ctrl+.", "ctrl+g"], "command": "go_guru_goto_definition", "args": {"output": false}, "context": [{ "key": "selector", "operator": "equal", "operand": "source.go" }] },
{"button": "button2", "modifiers": ["ctrl"], "press_command": "drag_select", "command": "go_guru", "args": {"mode": "definition", "output": false }}

Refactoring

Generate Tests

{
"GOPATH": "/home/arsham/Projects/Go",
}
[
{"caption": "Generate Go Tests", "command": "gotests"},
]

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store