go的開發環境配置

來源:互聯網
上載者:User

標籤: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‘
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.