標籤:des style http java os io ar art
GO_DEV_TOOLsublime text2
下載
安裝package control
開啟後,按ctrl + ~開啟命令列,或者在view->show console,複製如下代碼,執行
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‘)
安裝gosublime,配置
{ "env": { "GOPATH": "~/workspace:$GS_GOPATH" }, "autocomplete_builtins": true, "autocomplete_suggest_imports": true}
安裝golint
golint用於檢測文法問題
go get github.com/golang/lint
golint filename
會提示一些規範錯誤,可將其部署到gosublime或者fswatch中去
安裝goimporter
go get code.google.com/p/go.tools/cmd/goimports
編譯好之後,設定一個ln -s到$GOBIN目錄(或者複製過去),並且將gosublime的user-setting添加一行
"fmt_cmd": ["goimports"]
注:ln -s 需要絕對路徑
fswatch熱編譯
go get github.com/codeskyblue/fswatch
build好之後串連到/usr/bin/fswatch
在需要目錄執行fswatch,產生.fswatch.json
然後在comman裡寫需要執行的命令,參考如下
{ "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"}
注意,faswtch不會自動殺掉啟動並執行那個進程,因此需要手動殺一下,再研究一下
將golint併入到監控目錄中去,方便修改內容
supervisor
[program:vehiclestat]command=~/workspace/vehicleStat/src/vehicleStat/vehicleStatautostart = trueautorestart = truestartsecs = 5user = rootredirect_stderr = truestdout_logfile = /var/log/supervisord/vehicleStat.log
其它
設定目前的目錄為$GOPATH
alias gopath=‘export GOPATH=`pwd` && echo $GOPATH‘