1.下载go
https://golang.org/dl/ 或者 https://studygolang.com/dl 下载
2.安装go
tar zxvf go1.8.1.linux-amd64.tar.gz
mv go /usr/local
cd /usr/local/
设置环境变量
vim /etc/profile
GO_HOME=/usr/local/go
export PATH=$PATH:$GO_HOME/bin
source /etc/profile
3.测试安装是否成功
go version
4.编写hello world
cd /usr/local/go/src
mkdir hello
cd hello
vim hello.go
程序如下:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
编译代码
go build hello.go
运行
./hello标签:语言,安装,fmt,usr,go,HOME,local,hello From: https://blog.51cto.com/u_13753753/5847698