Go言語のインストールと IDE の設定までの手順メモ
検証環境
Windows10 Home Edition
Go言語のインストール
ダウンロード
こちらのサイトから Windows版のアーカイブファイルをダウンロードする (2018年3月31日現在、最新バージョンは 1.10.1)
今回はインストーラ(msi)を使わず、zip から手動でインストールした
Downloads - The Go Programming Language
インストール
ダウンロードした zip を適当なディレクトリに解凍する (以下、D:\prog\go に解凍したものとして説明する)
環境変数
"システムのプロパティ" → "詳細設定" → "環境変数" で GOROOT、GOPATH、PATH の環境変数を設定する
設定の基準は下記の通り
GOROOT
Go言語のインストール先のパス (今回は D:\prog\go)
GOPATH
go get で取得するパッケージやプロジェクトの配置先 (例、D:\home\takaya030\go)
PATH
%GOROOT%\bin と %GOPATH%\bin を PATH に追加する
動作確認
go version や go help が動作するか確認する
D:\>go version go version go1.10.1 windows/amd64 D:\>go help Go is a tool for managing Go source code. Usage: go command [arguments] The commands are: build compile packages and dependencies clean remove object files and cached files doc show documentation for package or symbol env print Go environment information bug start a bug report fix update packages to use new APIs fmt gofmt (reformat) package sources generate generate Go files by processing source get download and install packages and dependencies install compile and install packages and dependencies list list packages run compile and run Go program test test packages tool run specified go tool version print Go version vet report likely mistakes in packages Use "go help [command]" for more information about a command. Additional help topics: c calling between Go and C buildmode build modes cache build and test caching filetype file types gopath GOPATH environment variable environment environment variables importpath import path syntax packages package lists testflag testing flags testfunc testing functions Use "go help [topic]" for more information about that topic.
開発ツールのインストール
D:\>go get -u -v github.com/Masterminds/glide D:\>go get -u -v github.com/nsf/gocode D:\>go get -v -v github.com/uudashr/gopkgs/cmd/gopkgs D:\>go get -u -v github.com/rogpeppe/godef D:\>go get -u -v sourcegraph.com/sqs/goreturns D:\>go get -u -v github.com/golang/lint/golint D:\>go get -u -v github.com/lukehoban/go-find-references D:\>go get -u -v github.com/lukehoban/go-outline D:\>go get -u -v golang.org/x/tools/cmd/gorename D:\>go get -u -v github.com/newhook/go-symbols D:\>go get -u -v golang.org/x/tools/cmd/guru D:\>go get -u -v github.com/derekparker/delve/cmd/dlv
Visual Studio Code のインストール
ダウンロード
こちらのサイトから Windows版のアーカイブファイルをダウンロードする (2018年3月31日現在、最新バージョンは 1.21.1)
今回はインストーラ(exe)を使わず、zip から手動でインストールした
code.visualstudio.com
パスの設定
D:\prog\VSCode-win32-x64-1.21.1\bin を PATH に追加する
Visual Studio Code の Go言語拡張のインストール
"拡張機能" から Go for Visual Studio Code をインストールする