CentOS 8.5にプログラム言語Goをインストールする

2021年12月21日

環境
# cat /etc/redhat-release
CentOS Linux release 8.5.2111

インストールの方法
1.有効になっているGoのストリームを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf module list go-toolset
CentOS Linux 8 - AppStream
Name Stream Profiles Summary
go-toolset rhel8 [d] common [d] Go
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
# dnf module list go-toolset CentOS Linux 8 - AppStream Name Stream Profiles Summary go-toolset rhel8 [d] common [d] Go Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
# dnf module list go-toolset
CentOS Linux 8 - AppStream
Name                                Stream                             Profiles                            Summary
go-toolset                          rhel8 [d]                          common [d]                          Go

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

2.Goをインストールします
# dnf module -y install go-toolset:rhel8

3.goバージョンを確認します
# go version
go version go1.16.7 linux/amd64

4.テストプログラムを作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat > test.go <<'EOF'
package main
import "fmt"
func main() {
fmt.Println("study go language !")
}
EOF
# cat > test.go <<'EOF' package main import "fmt" func main() { fmt.Println("study go language !") } EOF
# cat > test.go <<'EOF'
package main
import "fmt"
func main() {
    fmt.Println("study go language !")
}
EOF

プログラムを実行します
# go run test.go
study go language !

CentOS8

Posted by arkgame