分享
centos7下配置golang1.7.1环境
ligaofeng · · 5013 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
环境(个人阿里云主机):
# hostnamectl Static hostname: iZ23nwzgx3sZ Icon name: computer-vm Chassis: vm Machine ID: 45461f76679f48ee96e95da6cc798cc8 Boot ID: 4022018209e04363871ed0279a30c225 Virtualization: xen Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-229.11.1.el7.x86_64 Architecture: x86-64 # lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.2.1511 (Core) Release: 7.2.1511 Codename: Core
到官方https://golang.org/dl/下载安装包
</pre><pre name="code" class="plain">#wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
# tar zxvf go1.7.1.linux-amd64.tar.gz -C /usr/local
新建GOPATH目录
# mkdir -p /mnt/wwwroot/gofile
# vim /etc/profile
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/mnt/wwwroot/gofile
:wq保存
使其生效
#source /etc/profile
查看是否配置成功
# go version
go version go1.7.1 linux/amd64
简单测试:
# cd /mnt/wwwroot/gofile
# vim hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
# go run hello.go
Hello, 世界
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信5013 次点击
上一篇:go web开发之url路由设计
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
环境(个人阿里云主机):
# hostnamectl Static hostname: iZ23nwzgx3sZ Icon name: computer-vm Chassis: vm Machine ID: 45461f76679f48ee96e95da6cc798cc8 Boot ID: 4022018209e04363871ed0279a30c225 Virtualization: xen Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-229.11.1.el7.x86_64 Architecture: x86-64 # lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.2.1511 (Core) Release: 7.2.1511 Codename: Core
到官方https://golang.org/dl/下载安装包
</pre><pre name="code" class="plain">#wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
# tar zxvf go1.7.1.linux-amd64.tar.gz -C /usr/local
新建GOPATH目录
# mkdir -p /mnt/wwwroot/gofile
# vim /etc/profile
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/mnt/wwwroot/gofile
:wq保存
使其生效
#source /etc/profile
查看是否配置成功
# go version
go version go1.7.1 linux/amd64
简单测试:
# cd /mnt/wwwroot/gofile
# vim hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
# go run hello.go
Hello, 世界