ubuntu 下安装go
1 安装C语言工具集(可选)
sudo apt-get install bison ed gawk gcc libc6-dev make
2 安装SCM 源代码控制管理工具Mercurial(可选)
go源码使用Mercurial管理
2.1 安装mercurial依赖
sudo apt-get install python-setuptools python-dev build-essential
2.2 安装mercurial
sudo easy_install mercurial
3 获取go的源代码
itang@itang-laptop:~/sources$ hg clone -r release https://go.googlecode.com/hg/ go
4 安装go
4.1 编译安装
itang@itang-laptop:~/sources$ cd go/src
itang@itang-laptop:~/sources/go/src$ ./all.bash
...
--- cd ../test
1 known bugs; 0 unexpected bugs
---
Installed Go for linux/386 in /home/itang/sources/go.
Installed commands in /home/itang/sources/go/bin.
*** You need to add /home/itang/sources/go/bin to your $PATH. ***
The compiler is 8g.
4.2 配置环境变量
itang@itang-laptop:~/sources/go/src$ gedit ~/.profile
在文件最后加上一下两行:
export GO_HOME=/home/itang/sources/go //改成自己的目录
export PATH=$GO_HOME/bin:$PATH
itang@itang-laptop:~/sources/go/src$ source ~/.profile
5 hello,world
5.1 coding
~/sources/go/src$ cd ~/test
~/test$ gedit hello.go
输入:
package main
import "fmt"
func main() {
fmt.Printf("hello, 世界\n")
}
5.2 编译/链接/运行
go run hello.go界
6 跟上go的最新发布
$ cd go/src
$ hg pull
$ hg update release
$ ./all.bash
1 安装C语言工具集(可选)
sudo apt-get install bison ed gawk gcc libc6-dev make
2 安装SCM 源代码控制管理工具Mercurial(可选)
go源码使用Mercurial管理
2.1 安装mercurial依赖
sudo apt-get install python-setuptools python-dev build-essential
2.2 安装mercurial
sudo easy_install mercurial
3 获取go的源代码
itang@itang-laptop:~/sources$ hg clone -r release https://go.googlecode.com/hg/ go
4 安装go
4.1 编译安装
itang@itang-laptop:~/sources$ cd go/src
itang@itang-laptop:~/sources/go/src$ ./all.bash
...
--- cd ../test
1 known bugs; 0 unexpected bugs
---
Installed Go for linux/386 in /home/itang/sources/go.
Installed commands in /home/itang/sources/go/bin.
*** You need to add /home/itang/sources/go/bin to your $PATH. ***
The compiler is 8g.
4.2 配置环境变量
itang@itang-laptop:~/sources/go/src$ gedit ~/.profile
在文件最后加上一下两行:
export GO_HOME=/home/itang/sources/go //改成自己的目录
export PATH=$GO_HOME/bin:$PATH
itang@itang-laptop:~/sources/go/src$ source ~/.profile
5 hello,world
5.1 coding
~/sources/go/src$ cd ~/test
~/test$ gedit hello.go
输入:
package main
import "fmt"
func main() {
fmt.Printf("hello, 世界\n")
}
5.2 编译/链接/运行
go run hello.go界
6 跟上go的最新发布
$ cd go/src
$ hg pull
$ hg update release
$ ./all.bash