Golang 在UBUNTU下 环境安装步骤

本文将指导您如何快速安装并配置Golang环境,包括下载、安装、设置环境变量、获取资源以及编写基本代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值