- WSLのUbuntuにGoをインストールする
- Ubuntu 16.04.4 LTS
- Go 1.10
手順
go/wiki/Ubuntu通りでOK
-
以下だと
1.6
がインストールされる$ sudo apt-get install golang-go
-
以下を実行する
$ sudo add-apt-repository ppa:gophers/archive $ sudo apt-get update $ sudo apt-get install golang-1.10-go
-
環境変数・PATH
- ファイルに追記
.zprofileexport GOPATH=$HOME/go export PATH=$PATH:/usr/lib/go-1.10/bin export PATH=$PATH:$GOPATH/bin
- シェル再ログイン
$ exec $SHELL -l
-
確認
$ go version $ go env
動作確認
-
フォルダの作成 (仮でWindowsのデスクトップに作る)
$ cd /mnt/c/Users/hoge/Desktop $ mkdir go-test $ cd go-test $ vim hello.go
-
ソース
hello.gopackage main import "fmt" func main() { fmt.Printf("hello, world\n") }
-
ビルド & 実行
$ go build hello.go $ ./hello