Debian11.2でGo言語1.17.8をインストールする

環境
# cat /etc/debian_version
11.2

Go言語をインストールします
1.Go言語のダウンロード
下記サイトに最新バージョンを確認します
https://go.dev/dl/

2.go1.17.8をダウンロードします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cd /usr/local/src
# wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
# cd /usr/local/src # wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
# cd /usr/local/src
# wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz

ダウンロードが終わったら、ファイルを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ls -l
合計 131744
-rw-r--r-- 1 root root 134902354 34 05:13 go1.17.8.linux-amd64.tar.gz
# ls -l 合計 131744 -rw-r--r-- 1 root root 134902354 3月 4 05:13 go1.17.8.linux-amd64.tar.gz
# ls -l
合計 131744
-rw-r--r-- 1 root root 134902354 3月 4 05:13 go1.17.8.linux-amd64.tar.gz

3.Go言語をインストールします
goファイルを指定「/usr/local」に解凍します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo tar -C /usr/local -xzf go1.17.8.linux-amd64.tar.gz
# sudo tar -C /usr/local -xzf go1.17.8.linux-amd64.tar.gz
# sudo tar -C /usr/local -xzf go1.17.8.linux-amd64.tar.gz

Go言語ディレクトリのファイルを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ls /usr/local/go
AUTHORS CONTRIBUTORS PATENTS SECURITY.md api codereview.cfg lib pkg test
CONTRIBUTING.md LICENSE README.md VERSION bin doc misc src
# ls /usr/local/go AUTHORS CONTRIBUTORS PATENTS SECURITY.md api codereview.cfg lib pkg test CONTRIBUTING.md LICENSE README.md VERSION bin doc misc src
# ls /usr/local/go
AUTHORS CONTRIBUTORS PATENTS SECURITY.md api codereview.cfg lib pkg test
CONTRIBUTING.md LICENSE README.md VERSION bin doc misc src

4.Goの環境パスを設定します
# nano $HOME/.profile
ファイルの最終行にパスを追加します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n 2> /dev/null || true
export PATH=$PATH:/usr/local/go/bin
# ~/.profile: executed by Bourne-compatible login shells. if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fi mesg n 2> /dev/null || true export PATH=$PATH:/usr/local/go/bin
# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi

mesg n 2> /dev/null || true
export PATH=$PATH:/usr/local/go/bin

最終行にパスの追記が終わったら、ファイルを反映します。
# source $HOME/.profile

5.Go言語のバージョンを確認します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# go version
go version go1.17.8 linux/amd64
# go version go version go1.17.8 linux/amd64
# go version
go version go1.17.8 linux/amd64

 

Debian 11

Posted by arkgame