Home > Backend Development > Golang > golang arm installation

golang arm installation

王林
Release: 2023-05-19 09:32:07
Original
1283 people have browsed it

With the popularity of ARM architecture processors, more and more developers are beginning to pay attention to how to develop on the ARM platform. As an efficient and concurrent programming language, Golang has gradually become a popular choice on the ARM platform. This article will introduce how to install Golang on ARM systems.

1. Download the Golang software package

First, we need to go to the Golang official website to download the Golang software package corresponding to the ARM architecture. Currently, the official website provides multiple versions of Golang software packages. We need to choose the software package that suits our system and architecture to download.

According to official documents, the currently officially supported ARM architectures are ARMv6, ARMv7 and ARM64. We can check the currently used system architecture through the following command:

$ uname -m
Copy after login

If it is ARMv6 or ARMv7, it is recommended to download a version before Golang 1.16; if it is ARM64, it is recommended to download Golang 1.16 or higher.

In this example, we will be using a Raspberry Pi 4 Model B, so the download is Golang version 1.16.

2. Install the Golang software package

After the download is completed, we need to unzip the Golang software package to the specified directory. Here, we choose to extract the software package to the /usr/local directory. /usr/local here is a convention, and third-party software is usually installed in this directory.

Execute the following command to decompress the software package to the /usr/local directory:

$ sudo tar -C /usr/local -xzf go1.16.linux-armv6l.tar.gz
Copy after login

After the decompression is completed, a go directory will be generated in the /usr/local directory, which contains Golang related files. In this directory, we can see the following files and directories:

go/
├── api
├── bin
├── lib
├── pkg
└── src
Copy after login

Among them, the bin, lib and pkg directories are some files and libraries required by the Golang compiler; the src directory contains all standard library source codes ; The api directory contains API documents for all versions of Golang.

Next, we need to configure Golang-related environment variables so that we can use Golang in the terminal.

3. Set Golang environment variables

Before setting Golang environment variables, we first need to confirm whether the following two paths are included in the current user's PATH variable:

/usr/local/go/bin
$HOME/go/bin
Copy after login

If neither of the above two paths are included in the PATH variable, you can add the following two lines of code to the ~/.bashrc file:

export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$HOME/go/bin
Copy after login

Note: If you are using zsh, please add the above code to the ~/.zshrc file.

Once the setup is completed, execute the following command directly in the terminal to see the Golang version installed in the current system:

$ go version
go version go1.16 linux/arm
Copy after login

At this point, we have successfully installed Golang on the ARM system. In the following development work, you can safely use Golang for program development.

The above is the detailed content of golang arm installation. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template