在Ubuntu上安装Go环境
打算将一篇论文中的存储引擎实现了,java效率相对低,不想用c++,就想到了google开源的go语言。这次是真的有实际需求的学习了。
开始安装:
- 安装c语言工具:gcc,make,awk等,一般默认都安装好了
- 安装Mercurial,sudo easy_install mercurial,
- 如果没有安装easy_install,执行:apt-get install python-setuptools python-dev build-essential
- 获取代码:hg clone -r release https://go.googlecode.com/hg/ go 会创建go目录。如果出现如下错误:
- abort: error: _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
- 解决方法,机器设置了代理,取消即可:export http_proxy=
- 到go/src之执行./all.bash,会有如下提示:
- --- 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.
- 按照提示,将路径加入到PATH中即可。
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
保存为hello.go.
编译:6g hell.go 生成hello.6,适用6l命令进行连接,生成6.out.执行。