centos安装GO

本文详细介绍了如何在Linux环境下安装并配置Go语言环境,包括下载、解压、添加环境变量等步骤,并通过创建和运行简单的Go程序来验证安装是否成功。


1,下载 go1.5.1.linux-amd64.tar.gz

2,将go解压到/opt,个人喜好罢了
[root@localhost ~]# tar -C /opt -xzf ./go1.5.1.linux-amd64.tar.gz

3,添加环境变量

GOPATH是工作目录,
GOROOT表示指出go的根目录位置 ps:在自定义程序的安装位置后,需要设置这个
export GOROOT=/opt/go
export PATH=$PATH:$GOROOT/bin
export GOPATH=$HOME/goTest
export GOBIN=$GOPATH/bin

[root@localhost ~]# vim /etc/profile

[root@localhost ~]# source /etc/profile

[root@localhost ~]# mkdir ./goTest/src/test

[root@localhost test]# touch ./hello.go

写入内容到hello.go:
package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

[root@localhost src]# cd ..

[root@localhost src]# go install test/hello.go
[root@localhost src]# $GOBIN/hello
hello, world

到这里,你的go就算安装好了。

转载于:https://www.cnblogs.com/zhaofeng555/p/4935785.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值