zoukankan      html  css  js  c++  java
  • Ubuntu 下安装 Google Go 语言

    首先打开:应用程序>附件>终端,

    创建一个 bin 目录用于存放编译后的程序目标文件(可选)
    命令中的 ~ 代表用户根目录。

    $ mkdir ~/bin

    然后用超级用户身份编辑用户配置文件,加入4个环境变量:

    $ sudo gedit ~/.bashrc
    输入密码,开始编辑配置文件。在尾部加入下列代码后,保存。

    export GOROOT=$HOME/go
    export GOARCH=386
    export GOOS=linux
    export GOBIN=$HOME/bin

    重新打开终端,开始 get GO 的源代码并编译之:

    apt-get install python-setuptools python-dev  
    sudo easy_install mercurial  
    hg clone -r release https://go.googlecode.com/hg/ $GOROOT  
    sudo apt-get install bison gcc libc6-dev ed make  
    cd $GOROOT/src  
    $ ./all.bash

    编译成功后,开始编写一个 hello world 程序测试之。
    依次建立目录层次 ~/projects/go/test1/ 作为工作目录.

    $ cd ~/projects/go/test1
    $ gedit test1.go

    在编辑器中输入如下代码:

    package main
    import "fmt"
    func main() {
        fmt.Printf("hello, world\n")
    }

    然后执行:

    $ 8g test1.go
    $ 8l test1.8
    $ ./8.out

    会打印出
    hello, world

    参考:
    http://golang.org/doc/install.html
    http://blog.csdn.net/LunnyXiao/archive/2010/01/12/5181194.aspx

  • 相关阅读:
    502 bad gateway错误的网关
    nodejs发展
    edgejs
    websocket nodejs实例
    nodejs原码
    node案例
    node 与php整合
    node c#
    jquery
    express
  • 原文地址:https://www.cnblogs.com/RChen/p/1797576.html
Copyright © 2011-2022 走看看