Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

Time:2022-5-3

1、 Go overview

Go is an open source programming language that can easily build simple, reliable and efficient software. It is statically typed and generates compiled machine code binaries. Go language is a compiled language, which is very popular among developers, because it means that there is no need to compile source code to create executable files. Therefore, installing and deploying go running environment in domestic operating system provides great convenience for development.

2、 Go features

Go is an open source programming language with the following features and functions:

● go performance is strong

Compared with other modern high-level languages (such as Java / Python), the biggest advantage of using C and C + + is their performance. Because C / C + + is a compiled language, not an interpreted language. The processor can only understand binary files. When running high-level languages such as Java and python, human readable code needs to be translated into bytecode, and then transformed into binary files that can be understood by the processor by a special interpreter. Like C and C + +, go language is also a compiled language. It directly compiles human readable code into binary files that the processor can run directly. It has higher execution efficiency and better performance.

● concise grammar

Go language is simple and easy to learn, and the learning curve is flat. It doesn’t need to take two to three years to learn like C / C + + language. Go language is called “C language in the Internet Era”. The style of go language is similar to C language. Its syntax is greatly simplified on the basis of C language, and the unnecessary expression brackets are removed. The loop has only one representation method of for, which can realize various traversal of values, key values and so on.

● uniform code style

Go language provides a set of formatting tools – go FMT. Some go language development environments or editors will use formatting tools to format the modified code when saving, which ensures that the code submitted by different developers is in a unified format.

3、 Go download

For go download, you can log in to golang Google China( https://golang.google.cn/dl/ ) download the corresponding installation package. In this chapter, we mainly deploy and install go based on the localized operating system in arm architecture. Therefore, we need to download the go package of Linux operating system. The version of go package downloaded this time is go1 18.linux-arm64. tar. gz。 Here, select the binary file corresponding to the operating system, such as go1 16.5. linux-arm64. tar. GZ for download

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

 

3、 Galaxy Unicorn

1. Unzip the installation package

Put the downloaded go1 18.linux-amd64. tar. Import GZ into Galaxy Kirin V10 operating system, obtain root permission, and unzip the installation package in the corresponding file path.

For example, here is a new go1.0 under the / usr / local / path Unzip the 18 pieces to get the go folder.

Decompression command:

tar zxvf go1.18.linux-amd64.tar.gz

The decompression result is shown in the figure:

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

 

2. Set environment variables

After extracting the go folder, we need to add the go environment variable. Here, we need to configure and set goroot, gopath and path.

Enter the environment variable configuration file, usually under the / etc / profile file.

Command: VIM / etc / profile

After entering the configuration file, add the following configuration at the end of the file:

export GOROOT=/usr/local/go1.18/go  

#Set the path to go installation. Some installation packages will automatically set the default goroot

export GOPATH=$HOME/go   

#Path to the default installation package

export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Add content as shown in the figure:

After adding the environment variables, WQ save and update the environment with source after exiting

source /etc/profile

Description of some basic configuration items of environment variables:

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

 

3. Whether the test is successful

3.1 view version

Open the terminal arbitrarily, enter the following command, and the following information appears, indicating that the installation is successful

go version

3.2. Program running test

Open the terminal and create hello.com in the workspace Go file, enter the following code, WQ save and exit.

package main

import “fmt”

func main() {

fmt.Printf(“hello, world\n”)

}

After exiting, you need to build the project and execute the command go build hello Go # will generate an executable file named hello and input commands from the terminal/ Hello, it will directly call the go language program to run, and output the print results, indicating that the installation and operation of go is successful.

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

Localization operating system Galaxy Kirin operating system V10 installation deployment go detailed explanation

 

Recommended Today

JS generate guid method

JS generate guid method https://blog.csdn.net/Alive_tree/article/details/87942348 Globally unique identification(GUID) is an algorithm generatedBinaryCount Reg128 bitsNumber ofidentifier , GUID is mainly used in networks or systems with multiple nodes and computers. Ideally, any computational geometry computer cluster will not generate two identical guids, and the total number of guids is2^128In theory, it is difficult to make two […]