当前位置: 移动技术网 > IT编程>脚本编程>Go语言 > ubuntu下搭建Go语言(golang)环境

ubuntu下搭建Go语言(golang)环境

2017年12月12日  | 移动技术网IT编程  | 我要评论

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

还是我自己的电脑,我自己安装的是ubuntu 12.04版本的,直接介绍安装吧!其实搭建环境很简单!

复制代码 代码如下:

sudo apt-get install python-setuptools python-dev build-essential //安装mercurial依赖
sudo easy_install mercurial                                       //安装mercurial

获取go语言包

复制代码 代码如下:
hg clone -r release https://go.googlecode.com/hg/ go

编译安装golang

复制代码 代码如下:

cd go/src
./all.bash

ubuntu到这里其实就安装成功了,要配置path了,就是我们的windows里的环境变量

复制代码 代码如下:

installed go for linux/386 in /home/widuu/source/go
installed commands in /home/widuu/source/go/bin
*** you need to add /home/widuu/source/go/bin to your path.

然后我们弄个文件试试

复制代码 代码如下:

sudo vim hello.go
package main
import "fmt"
func main() {
        fmt.printf("hello, 微度网络\n")
}
go build hello.go
./hello

输出hello,微度网络

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网