19
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Go WSLのUbuntuにGoをインストールする

Last updated at Posted at 2018-07-19
  • 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

    • ファイルに追記
    .zprofile
    export GOPATH=$HOME/go
    export PATH=$PATH:/usr/lib/go-1.10/bin
    export PATH=$PATH:$GOPATH/bin
    
    • シェル再ログイン
    $ exec $SHELL -l
    
  • 確認

    $ go version
    $ go env
    

動作確認

  • Test your installationを実施する

  • フォルダの作成 (仮でWindowsのデスクトップに作る)

    $ cd /mnt/c/Users/hoge/Desktop
    $ mkdir go-test
    $ cd go-test
    $ vim hello.go
    
  • ソース

    hello.go
    package main
    
    import "fmt"
    
    func main() {
        fmt.Printf("hello, world\n")
    }
    
  • ビルド & 実行

    $ go build hello.go
    $ ./hello
    

参考

19
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?