版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39138071/article/details/80255517
1、安装go
sudo apt-get install golang-go
2、设置go环境变量
export GOROOT=$HOME/go
export PATH=$GOROOT/bin:$PATHU
3、新建一个文件hello.go,在里面写入内容
package main
import (
"fmt"
"runtime"
)
func main() {
fmt.Println("Hellow World!", runtime.Version())
}
4、运行
go run hello.go //注:要进入到保存hello.go的文件目录下运行
或者 go build hello.go ,将生成的 hello.sh 文件,通过linux 命令 ./hello 运行。
结果显示如下,则说明成功
Hellow World! go1.6.2