参考官方文档:https://golang.org/doc/install/source

(因为被墙)可以看国内地址: http://godoc.golangtc.com/doc/install/source

http://godoc.golangtc.com/doc/code.html

还有这2个帖子

http://studygolang.com/articles/2599

http://studygolang.com/articles/2390

http://blog.csdn.net/qinxiandiqi/article/details/42918067

修改软件源

注意

1.版本信息,ubuntu每个版本的英文 名字都不一样, 添加 源版本不一致 也无法工作。所以要根据自己的版本来添加。

查看自己的版本信息   http://www.cnblogs.com/scotth/p/3979564.html

2.这个是树莓派的源

sudo vim /etc/apt/source.list

我的source.list

#替换国内源

#中山大学
deb http://mirror.sysu.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi #中国科学技术大学
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi #清华大学
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi #华中科技大学
#deb http://mirrors.hustunique.com/raspbian/raspbian/ wheezy main contrib non-free rpi
#Arch Linux ARM http://mirrors.hustunique.com/archlinuxarm/ wheezy main contrib non-free rpi #大连东软信息学院源(北方用户)
#deb http://mirrors.neusoft.edu.cn/raspbian/raspbian/ wheezy main contrib non-free rpi #重庆大学源(中西部用户)
#deb http://mirrors.cqu.edu.cn/Raspbian/raspbian/ wheezy main contrib non-free rpi #新加坡国立大学
#deb http://mirror.nus.edu.sg/raspbian/raspbian wheezy main contrib non-free rpi #牛津大学
#deb http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/ wheezy main contrib non-free rpi #韩国KAIST大学
#deb http://ftp.kaist.ac.kr/raspbian/raspbian/ wheezy main contrib non-free rpi #官网的源
#deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi # Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian/ wheezy main contrib non-free rpi
 
 
1 修改sources.list
    【备份】
    在修改之前先把源列表备份,然后再修改sources.list
    cd /etc/apt
    cp sources.list sources.list_back
    【修改】
    sudo vim sources.list
   例如使用大连东软信息学院软件源镜像,修改之后的内容如下:

deb http://mirrors.neusoft.edu.cn/raspbian/raspbian wheezy main contrib non-free rpi

    记得格式一定要正确!!!!!!
 
2 更新软件源和软件
    # 更新软件源
    sudo apt-get update
    # 更新软件
    sudo apt-get upgrade

apt-cache search string  //在源软件列表中查找相应的软件包

pi@raspberrypi /etc/apt $ sudo apt-cache search golang
golang - Go programming language compiler - metapackage
golang-dbg - Go programming language compiler - debug files
golang-doc - Go programming language compiler - documentation
golang-go - Go programming language compiler
golang-mode - Go programming language - mode for GNU Emacs
golang-src - Go programming language compiler - source files

然后安装apt-get install golang-go

目前树莓派上的自带包的版本是1.0.2

官方golang 是最新版本是1.4.2

http://golangtc.com/download

根据自己要求下

树莓派是32bit linux ===》 go1.4.2.linux-386.tar.gz go1.4.2 Linux (x86 32-bit) tarball

解压 tar -zxvf go1.4.2.linux-386.tar.gz

解压路径就在 /home/pi/

#cd ~pi/go/src

cd /home/pi/go/src 

开始编译go

./all.bash

当出现

ALL TESTS PASSED

表示编译成功

PS.我曾经mount windows目录来编译GO,出现了一些问题,

切记 go1.4.2.linux-386.tar.gz 包解压路径 一定要是linux的路径,而不是网络路径(windows 共享目录)

否则编译出错

=======================================

配置golang运行环境变量

3.2 GOOS和GOARCH

分别代表编译的目标系统和平台,可选值如下:

GOOS GOARCH
darwin 386
darwin amd64
dragonfly 386
dragonfly amd64
freebsd 386
freebsd amd64
freebsd arm
linux 386
linux amd64
linux arm
netbsd 386
netbsd amd64
netbsd arm
openbsd 386
openbsd amd64
plan9 386
plan9 amd64
solaris amd64
windows 386
windows amd64

需要注意的是这两个值代表的是目标系统和平台,而不是编译源代码的系统和平台。树莓派的RaspBian是linux系统,所以这些GOOS设置为linux,GOARCH设置为arm。

1.

 修改 ~/.bashrc  来添加环境变量

//export GOROOT=$HOME/go
//export PATH=$PATH:$GOROOT/bin

GOROOT=你的go目录路径

export GOROOT=/home/pi/go
export GOARCH=arm
export GOOS=linux
export GOARM=7
export GOBIN=/home/pi/go/bin
export PATH=$PATH:$GOROOT/bin

其中

$GO386 (for 386 only, default is auto-detected if built on either 386 or amd64, 387 otherwise)  设置指令集

$GOARM (for arm only; default is auto-detected if building on the target processor, 6 if not) 设置ARM CPU版本

这2个系统会自动识别。可以不加

具体参考http://godoc.golangtc.com/doc/install/source

记得  source ~/.profile 或者  source ~/.bashrc  使配置文件生效

相关知识点看这里  在 Ubuntu 系统中有三种设置环境变量 PATH 的方法

最后执行

go version

如果显示 【go version go1.4.2 linux/arm  】则表示安装ARM 成功

raspberry安装go的更多相关文章

  1. Win10 IoT C#开发 1 - Raspberry安装IoT系统及搭建开发环境

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. The ...

  2. Raspberry 安装vstudio

    Visual Studio Code微软公司推出的一款轻量级的Visual Studio风格的跨平台的IDE.当然,除了Windows,OSX,还能在树莓派上使用.目前树莓派上可用的IDE真不多,VS ...

  3. Linux (raspberry) 安装 telnet server

    可能由于内核或者版本问题 ,网上的telnet服务器安装教程,总是无法安装成功 ,下面说说基于debian发行版(树莓派)telnet 服务器端的安装,便于以后的远程访问. 具体可以通过netstat ...

  4. raspberry pi恢复jessie镜像之后

    1.更新源 nano /etc/apt/source.list deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib ...

  5. Win10 IoT C#开发 6 - 4x4矩阵键盘扫描

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. 上一章我 ...

  6. Win10 IoT C#开发 5 - 操作 IoT 设备内嵌 SQLite 数据库 CURD

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. 前几章我 ...

  7. Win10 IoT C#开发 2 - 创建基于XAML的UI程序 及 应用的三种部署方法

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. 上一章我 ...

  8. Win10 IoT C#开发 3 - GPIO Pin 控制发光二极管

    Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架构上运行. 上一篇文 ...

  9. 4x4矩阵键盘扫描

    4x4矩阵键盘扫描 Windows 10 IoT Core 是微软针对物联网市场的一个重要产品,与以往的Windows版本不同,是为物联网设备专门设计的,硬件也不仅仅限于x86架构,同时可以在ARM架 ...

随机推荐

  1. C#对象实例化

    C#常用的对象实例化有以下几种方式: using System; using System.Collections.Generic; using System.Linq; using System.R ...

  2. LeetCode85 Maximal Rectangle java题解

    public static int maximalRectangle(char[][] matrix) { int rowNum=matrix.length; if(rowNum==0) return ...

  3. c语言知识点总结-------静态区、堆、栈、常量区等

    在C语言中地址占4个字节 1.编程语言发展 低级语言----->高级语言 机器语言 ---> 汇编---->高级语言(C语言.C++.JAVA等) 机器语言 :0101 0010 1 ...

  4. Android录屏命令、Android录Gif、Android录视频

    NoHttp开源地址:https://github.com/yanzhenjie/NoHttp NoHttp具体使用文档已公布,你想知道的全都有,请点我移步! 版权声明:转载请注明本文转自严振杰的博客 ...

  5. React - S1

    资料: 1. https://developer.mozilla.org/zh-CN/docs/Web/JavaScript 进度: 教程 - 高级内容remaining; 参考remaining j ...

  6. php 获取当前页面url路径

    #测试网址: http://localhost/blog/testurl.php?id=5 //获取域名或主机地址 echo $_SERVER['HTTP_HOST'].""; # ...

  7. 九度OJ 1086:最小花费 (DP)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3960 解决:819 题目描述: 在某条线路上有N个火车站,有三种距离的路程,L1,L2,L3,对应的价格为C1,C2,C3.其对应关系如下 ...

  8. 看不懂JDK8的流操作?5分钟带你入门(转)

    在JDK1.8里有两个非常高级的新操作,它们分别是:Lambda 表达式和 Stream 流. Lambda表达式 让我们先说说 Lambda 表达式吧,这个表达式最大的作用就是简化语法,让代码更加易 ...

  9. mapper代理(十一)

    原始 dao开发问题 1.dao接口实现类方法中存在大量模板方法,设想能否将这些代码提取出来,大大减轻程序员的工作量. 2.调用sqlsession方法时将statement的id硬编码了 3.调用s ...

  10. linux host=${host:-"localhost"}使用方法

    localhost=${host:-"localhost"} host 变量未设定或者为空,host取"-"后面的值;否则host=$host host=${h ...