64位树莓派上安装和配置golang1.9.2

本文实战了64位树莓派环境下安装和配置golang1.9.2的过程;

准备工作

硬件环境:树莓派3B设备
操作系统:64位Debian
有关操作系统的安装步骤请参考文章《树莓派3B安装64位操作系统(树莓派无需连接显示器键盘鼠标)》

安装

  1. 下载Go安装包,推荐在Golang中国下载,地址是:https://www.golangtc.com/download
  2. 注意要下载arm64格式的,如下图红框所示:注意要下载arm64格式的,如下图红框所示:
    在这里插入图片描述
  3. 将下载好的go1.9.2.linux-arm64.tar.gz文件复制到树莓派的/usr/local目录下,执行解压命令tar -zxvf go1.9.2.linux-arm64.tar.gz,发现/usr/local目录下多了个go目录,也就是解压后的文件夹;

安装结束,接下来是配置工作;

配置

  1. 创建文件夹/usr/local/go_workspace,我们以此文件夹作为工作区;
  2. 用vi打开~/.bash_profile文件,在末尾增加以下内容:
export GOPATH=/usr/local/go_workspace
export GOROOT=/usr/local/go
export GOBIN=$GOPATH/bin
export GOTOOLS=$GOROOT/pkg/tool
export PATH=$PATH:$GOBIN:$GOTOOLS:$GOROOT/bin
  1. 使配置生效:source ~/.bash_profile
  2. 输入go version验证,可以看到内容go version go1.9.2 linux/arm64,安装成功;

验证

  1. 创建文件夹/usr/local/go_workspace/src/hello/
  2. 在/usr/local/go_workspace/src/hello/目录下创建hello.go文件,内容如下:
package main

import "fmt"

func main() {
        fmt.Printf("hello, world\n")
}
  1. 验证直接运行:在/usr/local/go_workspace/src/hello/目录下,执行命令go run hello.go,可以成功执行:
root@merak:/usr/local/go_workspace/src/hello# go run hello.go 
hello, world
  1. 验证编译构建:在/usr/local/go_workspace/src/hello/目录下,执行命令go build,执行后当前目录下多了个hello文件,如下图红框所示:
    在这里插入图片描述
    运行此文件,和go run hello.go效果一样;

  2. 验证install:在/usr/local/go_workspace/src/hello/目录下,执行命令go install,执行后/usr/local/go_workspace/目录下多了个bin文件夹,里面有个hello文件,运行此文件,和go run hello.go效果一样,如下图所示:
    在这里插入图片描述

至此,树莓派的Go语言环境搭建完成,一起来体验这个热门的语言吧!

欢迎关注我的公众号:程序员欣宸

在这里插入图片描述

Full Stack Web development with Raspberry Pi 3 By 作者: Soham Kamani ISBN-10 书号: 1788295897 ISBN-13 书号: 9781788295895 Release 出版日期: 2017-11-06 pages 页数: (268) List Price: $34.99 Book Description Key Features Leverage JavaScript, HTML5, and Cloud APIs to create visual representations and interactive web). Learn to install and use a Node.js-based web framework to develop Raspberry Pi 3-powered web applications. A step-by-step guide that will cover from setting up a embedded system to developing embedded, device-powered interactive web applications. Book Description Modern web technology and portable computing together have enabled huge advances in the Internet of Things (IoT) space,as well as in areas such as machine learning and big data. The Raspberry Pi is a very popular portable computer for running full stack web applications. This book will empower you to master this rapidly evolving technology to develop complex web applications and interfaces. This book starts by familiarizing you with the various components that make up the web development stack and that will integrate into your Raspberry Pi-powered web applications. It also introduces the Raspberry Pi computer and teach you how to get up and running with a brand new one. Next, this book introduces you to the different kinds of sensor you’ll use to make your applications; using these skills, you will be able to create full stack web applications and make them available to users via a web interface. Later, this book will also teach you how to build interactive web applications using JavaScript and HTML5 for the visual representation of sensor data. Finally, this book will teach you how to use a SQLite database to store and retrieve sensor data from multiple Raspberry Pi computers. By the end of this book you will be able to create complex full stack web applications on the Raspberry Pi 3 and will have improved your application’s performance and usability. What you will learn Get up and running with your Raspberry Pi Go full stack! Learn about the end-to-end development process for web applications, right from the OS up to the actual HTML web interface Discover that JavaScript is one of the fastest growing languages today, and is the only language that can be used both on a browser and server. This book will empower you to develop in a complete JavaScript stack See that the IoT is everywhere!Connect your application to the outside world. Make use of sensors in your Raspberry Pi to give your application an edge, and unleash the full power of the Internet of Things Build a rich UI with beautiful charts and data visualizations that can run on any browser Make your software data-driven. Learn how to utilize SQLite to collect and analyze data from multiple systems About the Author Soham Kamani is a full-stack developer who has extensive experience in the JavaScript ecosystem. He works as a consultant, developing end-to-end web-based solutions for clients around the world. He is an open source enthusiast and an avid blogger. He has worked on many frameworks and technologies such as React, Angular, Node, Express, Sails, SQLite, Postgres, and MySQL, and he has worked on many projects in the IoT space using Arduino and Raspberry Pi systems. Contents Chapter 1. Getting Started on the Raspberry Pi Chapter 2. Getting Up-and-Running with Web Development on the Raspberry Pi Chapter 3. Running a Node Server on the Pi Chapter 4. Extracting Information from the GPIO Pins Chapter 5. Retrieving Sensor Readings from the Server Chapter 6. Creating a Web Page to Display Sensor Data Chapter 7. Enhancing Our UI – Using Interactive Charts Chapter 8. SQLite – The Fast and Portable Database Chapter 9. Integrating SQLite into Our Application Chapter 10. Making our Application Real Time with Web Sockets Chapter 11. Deploying our application to Firebase Chapter 12. Using Firebase APIs to Update Our Application
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员欣宸

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值