加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Golang 在UBUNTU下 环境安装步骤

发布时间:2020-12-16 19:02:51 所属栏目:大数据 来源:网络整理
导读:1,环境变量设置 --| cd --| mkdir go --| mkdir bin --| sudo gedit .bashrc 在bash文件的最后添加如下代码来设置目录变量: export GOROOT=$HOME/go export GOOS=linux export GOARCH=386 export GOBIN=$HOME/bin 保存文件 --|source .bashrc --|sudo /etc

1,环境变量设置

--| cd

--| mkdir go

--| mkdir bin

--| sudo gedit .bashrc

在bash文件的最后添加如下代码来设置目录变量:

export GOROOT=$HOME/go
export GOOS=linux
export GOARCH=386
export GOBIN=$HOME/bin
保存文件
--|source .bashrc
--|sudo /etc/profile
在文件最后修改PATH,PATH尚未存在,直接添加如下语句,否则添加

export PATH=$HOME/bin:$PATH
保存文件
--|source /etc/profile
执行env | grep '^GO'测试是否已经正确设置GO的环境变量

2,获取资源

--|hg clone -r release https://go.googlecode.com/hg/ $GOROOT

如果不成功,则先安装mercurial:

--|sudo apt-get install mercurial

3,安装

--|sudo apt-get install bison gcc libc6-dev ed

--|cd $GOROOT/src

--|./all.bash

等待几分钟,最后它会自测出现--- cd ../test

--| cd

--|mkdir helloGo
--|cd helloGo
--|cat >hello.go <<EOF
--|package main
--|import "fmt"
--|func main() {
--|fmt.Printf("hello,world/n"
--|}
--|EOF
--|8g hello.go
--|8l hello.8
--|./8.out
hello,world

4,参考

1,golang官网http://golang.org/

2,我的MSN golang@live.cn

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读