安装
wget https://dl.google.com/go/go1.19.5.linux-amd64.tar.gz
tar zxvf go1.19.5.linux-amd64.tar.gz -C /usr/local/
# vim /etc/profile ###添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
source /etc/profile
运行go程序
root@172.16.17.127[/zc/golang]# cat hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello World!!!")
}
root@172.16.17.127[/zc/golang]# go run hello.go
Hello World!!!
编译go程序
root@172.16.17.127[/zc/golang]# go build hello.go
root@172.16.17.127[/zc/golang]# ls
hello hello.go
root@172.16.17.127[/zc/golang]# ./hello
Hello World!!!