个人工具

“Golang”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
golang安装
golang安装
第14行: 第14行:
 
$ cd go/src
 
$ cd go/src
 
$ ./all.bash
 
$ ./all.bash
 +
</pre>
 +
假如正常的话,会出现下面的信息
 +
<pre>
 +
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. ***
 +
The compiler is 6g.
 +
</pre>
 +
*配置系统环境
 +
你在~/.bashrc或者 ~/.profile写入你的配置文件,下面我会以.bashrc来说明;
 +
那么,golang要设置那些变量呢?
 +
1、$GOROOT 
 +
golang的目录,这里我们是~/go
 +
2、$GOOS 和 $GOARCH 
 +
系统的参数
 +
设置方法如下:
 +
<pre>
 +
$GOOS $GOARCH
 +
darwin 386
 +
darwin amd64
 +
freebsd 386
 +
freebsd amd64
 +
linux 386
 +
linux amd64
 +
linux arm incomplete
 +
windows 386 incomplete
 +
</pre>
 +
3、$GOBIN
 +
golang的bin目录,这里是~/go/bin
 +
下面是一个配置例子:请大家特别注意$GOOS 和 $GOARCH  的配置
 +
<pre>
 +
$ gedit ~/.bashrc
 +
</pre>
 +
然后加入
 +
<pre>
 +
export GOROOT=~/go
 +
export GOARCH=386
 +
export GOOS=linux
 +
epxort GOBIN=GOROOT/bin
 +
export PATH=$PATH:$GOBIN
 
</pre>
 
</pre>

2011年12月29日 (四) 11:10的版本

golang的简介

Go语言是谷歌2009发布的第二款开源编程语言。Go语言专门针对多处理器系统应用程序的编程进行了优化,使用Go编译的程序可以媲美C或C++代码的速度,而且更加安全、支持并行进程。

golang安装

golang目前有两种编译,一个是golang官方提供的,另一个是gnu提供的gccgo 下面介绍golang官方的工具安装 *安装gcc工具,因为golang有些功能是使用c写的,所以构建golang的编译是必须的

$ sudo apt-get install bison gawk gcc libc6-dev make
  • 安装mercurial工具,目的使用hg命令来提取golang的源代码
$ sudo apt-get install mercurial
  • 代取提取,如果您的网速比较慢的话,此步要多花点时间
$ hg clone -u release https://go.googlecode.com/hg/ go
  • 编译golang
$ 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. ***
The compiler is 6g.

*配置系统环境 你在~/.bashrc或者 ~/.profile写入你的配置文件,下面我会以.bashrc来说明; 那么,golang要设置那些变量呢? 1、$GOROOT golang的目录,这里我们是~/go 2、$GOOS 和 $GOARCH 系统的参数 设置方法如下:

	$GOOS 	$GOARCH 	
	darwin 	386
	darwin 	amd64
	freebsd 	386
	freebsd 	amd64
	linux 	386
	linux 	amd64
	linux 	arm 	incomplete
	windows 	386 	incomplete

3、$GOBIN golang的bin目录,这里是~/go/bin 下面是一个配置例子:请大家特别注意$GOOS 和 $GOARCH 的配置

$ gedit ~/.bashrc

然后加入

export GOROOT=~/go
export GOARCH=386
export GOOS=linux
epxort GOBIN=GOROOT/bin
export PATH=$PATH:$GOBIN