VS CodeでGoプラグラムを実行

VS Codeとは

Visual Studio CodeMicrosoftが開発したVisualStudioの軽量版でWebアプリケーション作成時に便利なIDEです。 今回はGo言語を使う際の設定のメモを書いておきます。

環境

Go言語用エクステンションの設定

VSCodeをインストールした後 Shift + Command + Pを押してコマンドパレットを開き、install Extensionと入力し、Goを選択してインストールする。インストール後再起動を行っておく。 f:id:scache:20160517022334p:plain

右下のAnalysis Tools Missingをクリックしてツールをインストールする。 f:id:scache:20160517022701p:plain

delveの設定

Go言語のデバッグを行う際にはdelveが必要になります。設定はdelve githubを見て行います。

$ xcode-select --install
  1. /Applications/Utilities/Keychain Access.appを開く
  2. メニューからKeychain Access -> Certificate Assistant -> Create a Certificateを選択
  3. 以下のように設定 f:id:scache:20160517031134p:plain
  4. Specify a Location For The Certificateの項目がでるまでcontinueをして、KeychainをSystemに変更して完了
  5. KeychainAccessに戻り、keychainsからSystemを選択する。delve-certを右クリックしてGet Infoを選択する。Trustを開き、Code SigningをAlways Trustに変更する。
  6. KeyAccessを閉じて、taskgatedを再起動またはコンピュータを再起動する
  7. ターミナルで、mkdir $GOPATH/src/github.com/derekparker && cd $GOPATH/src/github.com/derekparker, git clone https://github.com/derekparker/delve.git && cd delveを実行する
  8. GO15VENDOREXPERIMENT=1 CERT=delve-cert make installを実行して終了

デバッグ実行

VSCodeに戻りgoプログラムを作成してF5を押すと実行ができます f:id:scache:20160517034507p:plain