ここの記述はすべてOSX10.11.4環境でのものです。
Goのインストール
$ brew install go
$ go version
go version go1.6 darwin/amd64
goが使用するdirectoryを設定します
$ echo 'export GOPATH="your go directory path"' >> ~/.bash_profile
各種ツールのインストール
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
先ほど設定したdirectoryにsourceがインストールされます
Editorの設定
- Visual Studio Codeを使います
-
$ code <directory or file>
でeditorを開けるようにメニューバーからView->Command Paletteを開き、commandを入力してinstall
code
command in PATH
を選択します - メニューバーからView->Command Paletteを開き、installを入力して
extensions install
を選択します - 検索boxにgoを入力して一番上のextension(Go)をインストールします
-
cmd+,
を入力してsetting.jsonを編集します
setting.json
// Place your settings in this file to overwrite the default settings
{
//-------- Editor configuration --------
"editor.fontSize": 14,
"editor.fontFamily": "monospace",
"editor.renderWhitespace": true,
"editor.glyphMargin": true,
"editor.cursorStyle": "block",
"editor.cursorBlinking": "visible",
"editor.tabSize": 2,
"editor.wrappingColumn": 80,
//-------- Files configuration --------
"files.autoSave": "afterDelay",
//-------- Go configuration --------
"go.gopath": "your go directory path",
"go.formatOnSave": false,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.formatTool": "goreturns"
}
参考: https://marketplace.visualstudio.com/items?itemName=lukehoban.Go
Google App Engine for Go SDKのインストール
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go
上からgo_appengine_sdk_darwin_amd64-1.9.35.zipをインストールします。
sdkのpathを通します。
$ echo 'export PATH="/path/to/sdk:$PATH' >> ~/.bash_profile
注) $PATHを忘れると悲惨なことになるので注意、念のため
開発
# directoryを作成します
$ mkdir -p /path/to/develop
$ cd /path/to/develop
$ code /path/to/develop
あとは https://cloud.google.com/appengine/docs/go/ の通りに作成すれば出来るはずです。
参考: https://github.com/koichiroo/react-appengine-golang-boilerplate
上は私が作ったものですが、よかったら参考にしてください。