-
Notifications
You must be signed in to change notification settings - Fork 0
Sublime Text 3 go lint, go imports & go vet
The simplest method of installation is through the Sublime Text console. The console is accessed via the ctrl+`
shortcut or the View > Show Console menu
.
then paste this command into the console :
import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
First we install gosublime by using package manager.
Open the package manager by click preferences > Package Control
on menubar.
Then select install packages
and type GoSublime
inside the search box. Click and install.
After GoSublime is installed, it automatically run go fmt
command everytime go file is saved. Now let's add goimports into gosublime.
We need to install goimports before integrating it with GoSublime. Install goimports using this command go get -u golang.org/x/tools/cmd/goimports
.
Then open GoSublime settings and add goformats in it by simply open Preferences > Package Settings > GoSublime > Settings-Default
then find fmt_cmd
and add goimports
in the bracket so it looks like this "fmt_cmd" : ["goimports"]
Install SublimeLinter by using package manager.
Open the package manager by click preferences > Package Control
on menubar.
Then select install packages
and type SublimeLinter
inside the search box. Click and install.
Also install SublimeLinter-contrib-golint
and SublimeLinter-contrib-govet