Go_dev_toolsublime text2
Download
Install package Control
After opening, press Ctrl + ~ Open the command line, or in view-> show console, copy the following code and execute
import urllib2,os,hashlib; h = ‘7183a2d3e96f11eeadd761d777e62404‘ + ‘e330c659d4bb41d3bdf022e94cab3cd0‘; pf = ‘Package Control.sublime-package‘; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( ‘http://sublime.wbond.net/‘ + pf.replace(‘ ‘, ‘%20‘)).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), ‘wb‘ ).write(by) if dh == h else None; print(‘Error validating download (got %s instead of %s), please try manual install‘ % (dh, h) if dh != h else ‘Please restart Sublime Text to finish installation‘)
Install gosublime and configure
{ "env": { "GOPATH": "~/workspace:$GS_GOPATH" }, "autocomplete_builtins": true, "autocomplete_suggest_imports": true}
Install golint
Golint is used to detect Syntax problems
go get github.com/golang/lint
golint filename
Some standard errors will be prompted. You can deploy them in gosublime or fswatch.
Install goimporter
go get code.google.com/p/go.tools/cmd/goimports
After compilation, set an ln-S to the $ Gobin directory (or copy the past), and add a line to the user-setting of gosublime.
"fmt_cmd": ["goimports"]
Note: ln-S requires an absolute path.
Fswatch hot Compilation
go get github.com/codeskyblue/fswatch
Connect to/usr/bin/fswatch after build
Execute fswatch in the desired directory to generate. fswatch. JSON
Then write the command to be executed in comman. refer to the following:
{ "paths": [ "." ], "depth": 2, "exclude": [], "include": [ "\\.(go|py|php|java|cpp|h|rb)$" ], "command": [ "bash", "-c", "pgrep server | xargs kill && golint ./ && go build server.go && ./server" ], "env": { "POWERD_BY": "github.com/codeskyblue/fswatch" }, "kill-signal": "KILL"}
Note: faswtch does not automatically kill the running process. Therefore, you need to manually kill the process and try again.
Merge golint into the monitoring directory to facilitate content modification.
Supervisor
[program:vehiclestat]command=~/workspace/vehicleStat/src/vehicleStat/vehicleStatautostart = trueautorestart = truestartsecs = 5user = rootredirect_stderr = truestdout_logfile = /var/log/supervisord/vehicleStat.log
Others
Set the current directory to $ gopath
alias gopath=‘export GOPATH=`pwd` && echo $GOPATH‘