参考:http://golang.org/doc/install/source
1. 下载go源代码
- sudo apt-get install mercurial
- hg clone -u release https://code.google.com/p/go
2. 编译安装go
- cd ~/go/src
- ./all.bash
安装完后会提示如下信息:
- ALL TESTS PASSED
- ---
- Installed Go for linux/amd64 in /home/you/go.
- Installed commands in /home/you/go/bin.
- *** You need to add /home/you/go/bin to your $PATH. ***
3. 测试go
vi hello.go:
- package main
- import "fmt"
- func main() {
- fmt.Printf("hello, world\n")
- }
运行:
- go run hello.go
更新go
- cd ~/go/src
- hg pull
- hg update release
- ./all.bash
有疑问加站长微信联系(非本文作者)