wget https://golang.google.cn/dl/go1.18.linux-amd64.tar.gz
Get the Go compiler installation files.
sudo tar -C /usr/local -zxvf go1.18.linux-amd64.tar.gz
Unzip the file to the /usr/local path.
export PATH=$PATH:/usr/local/go/bin
Add the Go compiler executable to system variables.
go version
Check the compiler version.
package main
import "fmt"
func main() {
fmt.Println("Hi, GO!")
}
Create a new go file.
go run hello.go
Run to see if the compiler works.