Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi: install golang #185

Open
hhstore opened this issue Mar 22, 2020 · 4 comments
Open

Raspberry Pi: install golang #185

hhstore opened this issue Mar 22, 2020 · 4 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Mar 22, 2020

related:

@hhstore
Copy link
Owner Author

hhstore commented Mar 22, 2020

树莓派4b 安装 golang:

  • 方法1: 默认 apt-get install golang 版本过低(go1.11)

apt-get install golang

树莓派4b, 应下载:go1.14.1.linux-armv6l.tar.gz

@hhstore
Copy link
Owner Author

hhstore commented Mar 22, 2020

方法1: 包管理工具

  • 截止当前, 基于包管理工具安装的 go 版本为 go1.11.6 linux/arm
  • 当前go 最新版已经是 go1.14, 所以这个方法不够好.
sudo apt-get update -y

# 安装: 
sudo apt-get install golang -y

# 版本查看: 
go version

$ go version
go version go1.11.6 linux/arm

# 干净卸载: 
sudo apt-get autoremove golang -y

@hhstore
Copy link
Owner Author

hhstore commented Mar 22, 2020

方法2: 官网下载源码安装:

image

  • 官网有2个源码包, 树莓派4b, 应下载: go1.14.1.linux-armv6l.tar.gz
# arm v6: (树莓派选择)
wget https://studygolang.com/dl/golang/go1.18.3.linux-armv6l.tar.gz

wget https://dl.google.com/go/go1.14.1.linux-armv6l.tar.gz
wget https://studygolang.com/dl/golang/go1.14.1.linux-armv6l.tar.gz

# arm v8: 
wget https://dl.google.com/go/go1.14.1.linux-arm64.tar.gz
wget https://studygolang.com/dl/golang/go1.14.1.linux-arm64.tar.gz

# 本地上传到树莓派: 
scp ./go1.14.1.linux-armv6l.tar.gz pi@192.168.2.199:/home/pi/Downloads

image

  • 安装步骤:
# 解压到 安装目录: 
tar -C /usr/local -xzvf  xxx
sudo tar -C /usr/local -xzf ./go1.14.1.linux-arm64.tar.gz


#  查看: 
ls -l /usr/local/go

  • 配置 go env:

# pi @ raspberrypi in /usr/local [21:49:43]
$ cat ~/.zprofile

# go path:

# go1.11+
export GO111MODULE=on;
export GOSUMDB=off;

# path:
export PATH=$PATH:/usr/local/go/bin



  • 查看 go 版本:
go version

$ go version
go version go1.14.1 linux/arm

$ which go
/usr/local/go/bin/go

# 查看 go env: 
go env

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@hhstore and others