源代码安装go

安装Mercurial

如何在Ubuntu上安装Mercurial?


sudo apt-get install python2.5
sudo apt-get install python-all-dev
sudo apt-get install python-setuptools
sudo easy_install -U mercurial
hg --version


安装GO
hg clone -u release https://code.google.com/p/go ~/dist
cd go/src
./all.bash


运行all.bash后,出现“ALL TESTS PASSED” 说明安装成功

在~/.bashrc文件中增加以下

export GOROOT=~/dist
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN


测试是否可以用命令中运行 #go
Go is a tool for managing Go source code.

Usage:

	go command [arguments]

The commands are:

    build       compile packages and dependencies
    clean       remove object files
    env         print Go environment information
    fix         run go tool fix on packages
    fmt         run gofmt on package sources
    get         download and install packages and dependencies
    install     compile and install packages and dependencies
    list        list packages
    run         compile and run Go program
    test        test packages
    tool        run specified go tool
    version     print Go version
    vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

    c           calling between Go and C
    gopath      GOPATH environment variable
    importpath  import path syntax
    packages    description of package lists
    testflag    description of testing flags
    testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.


官方有一种更简单的方式安装
1.下载go源代码
wget http://go.googlecode.com/files/go1.2.linux-amd64.tar.gz

2.解压到/usr/local 目录下
tar -C /usr/local -xzf go1.2.linux-amd64.tar.gz

3.增加到PATH中
在/etc/profile或者 $HOME/.profile中增加
export PATH=$PATH:/usr/local/go/bin

4.运行go测试是否成功


参考: http://blog.csdn.net/tony1130/article/details/3739695

你可能感兴趣的:(go 安装)