Think Twice
IT技術メモ | Go言語のメモ
Created: 2021-09-24 / Updated: 2021-09-24

Windows環境(WSL)にGo言語をインストール


目次


Goenvとは

インストール

クローンしてくる

Copy
$ git clone https://github.com/syndbg/goenv.git ~/.goenv

環境変数を追加

設定を反映

Copy
$ source ~/.bashrc

インストール可能なバージョンを確認

Copy
$ goenv install -l
Available versions:
  1.2.2
  1.3.0
    :
    : (中略)
    :
  1.16.7
  1.16.8
  1.17.0
  1.17beta1
  1.17rc1
  1.17rc2
  1.17.1

今回は、1.17.1をインストールします。

Copy
$ goenv install 1.17.1

Goのバージョンを設定と確認

Copy
$ goenv global 1.17.1
$ goenv rehash
$ goenv version
1.17.1 (set by /home/fumo/.goenv/version)

動作確認

Copy
$ go
Go is a tool for managing Go source code.

Usage:

        go <command> [arguments]

The commands are:

        bug         start a bug report
        build       compile packages and dependencies
        clean       remove object files and cached files
        doc         show documentation for package or symbol
        env         print Go environment information
        fix         update packages to use new APIs
        fmt         gofmt (reformat) package sources
        generate    generate Go files by processing source
        get         add dependencies to current module and install them
        install     compile and install packages and dependencies
        list        list packages or modules
        mod         module maintenance
        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:

        buildconstraint build constraints
        buildmode       build modes
        c               calling between Go and C
        cache           build and test caching
        environment     environment variables
        filetype        file types
        go.mod          the go.mod file
        gopath          GOPATH environment variable
        gopath-get      legacy GOPATH go get
        goproxy         module proxy protocol
        importpath      import path syntax
        modules         modules, module versions, and more
        module-get      module-aware go get
        module-auth     module authentication using go.sum
        packages        package lists and patterns
        private         configuration for downloading non-public code
        testflag        testing flags
        testfunc        testing functions
        vcs             controlling version control with GOVCS

Use "go help <topic>" for more information about that topic.

参考

参考サイト

参照