LoginSignup
0
0

More than 1 year has passed since last update.

Rocky Linux 8.4にGo環境をインストール(Linux)

Last updated at Posted at 2022-04-13

linuxのOSにGo環境をインストールする手順です。

今回はRocky Linux 8.4を使用しています
※Centos8系は同手順で同様にインストールできる認識

手順

cd /usr/local

バージョン15をインストール(2022年4月時点の最新バージョンは17)

wget https://golang.org/dl/go1.15.2.linux-amd64.tar.gz

tar -C /usr/local -xzf go1.15.2.linux-amd64.tar.gz

rm -rf go1.15.2.linux-amd64.tar.gz

バージョン確認

go version
go version go1.15.2 linux/amd64

環境変数を設定

vi .bash_profile

export ROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$ROOT/bin

#設定後読み込み
source ~/.bash_profile

ホームディレクトリでhello.goを作成し下記を入力

vi hello.go

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

コマンド実行

go run hello.go
hello, world

完了!

0
0
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
0
0