当前位置 博文首页 > ubuntu下搭建Go语言(golang)环境

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

    作者:admin 时间:2021-02-09 15:03

    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,微度网络

    js
    下一篇:没有了