Linux supports go language because go language can be cross-platform. Due to its modular design and modularity, that is, the code is compiled and converted into the smallest possible binary form, therefore, the Go language does not require dependencies and supports platform independence; its code can be run on any platform (Windows, Linux, Mac OS etc.) and can be compiled on any server and application.
The operating environment of this tutorial: linux7.3 system, GO version 1.18, Dell G3 computer.
Go is a procedural programming language that can be used for fast machine code compilation. It is a statically typed compiled language. It provides a concurrency mechanism that makes it easy to develop multi-core and networked machine-level programs. It is a fast, dynamically typed and interpreted language; it provides support for interfaces and type embedding.
Linux supports go language because go language can be cross-platform.
Go language, like Java language, supports platform independence. Due to its modular design and modularity, i.e. the code is compiled and converted into the smallest possible binary form, therefore, it requires no dependencies. Its code can be compiled on any platform (Windows, Linux, Mac OS, etc.) and can be compiled on any server and application.
No need to use a virtual machine, the Go language code can be directly output as a binary executable file. Moreover, the Go language has its own linker and does not rely on the compiler and linker provided by any system. Therefore, the compiled binary executable file can run in almost any system environment.
Building a Go language development environment on Linux
##1. Install the Go language development package
You can check out the installation package (https://golang.google.cn/dl/) on the Go language official website. The development package has two versions, 32-bit and 64-bit. You need to choose different ones according to the situation of the reader’s computer. version of. Copy the download link of the Go language development package (https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz). Then, use the cd command in the terminal to enter the directory where you store the installation package (the /usr/local/ directory is used here, readers can also use other directories).root@ububtu:~# cd /usr/local/ root@ububtu:/usr/local#
root@ububtu:/usr/local# wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz --2019-11-06 10:47:23-- https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz 正在解析主机 dl.google.com (dl.google.com)... 203.208.39.196, 203.208.39.193, 203.208.39.200, ... 正在连接 dl.google.com (dl.google.com)|203.208.39.196|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度: 120054682 (114M) [application/octet-stream] 正在保存至: “go1.13.4.linux-amd64.tar.gz” go1.13.4.linux 43% 49.44M 3.56MB/s 剩余 16s ^go1.13.4.linux 100% 114.49M 4.73MB/s 用时 31s 2019-11-06 10:47:56 (3.67 MB/s) - 已保存 “go1.13.4.linux-amd64.tar.gz” [120054682/120054682])
root@ububtu:/usr/local# tar -C /usr/local -xzf go1.13.4.linux-amd64.tar.gz
root@ububtu:/usr/local/go# bin/go version go version go1.13.4 linux/amd64
Configuring environment variables
We need to configure 2 environment variables, GOROOT and PATH.export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOBIN
:wq command to save and exit.
source /etc/profile command to make the configuration file take effect. Now you can use Go language commands in any directory.
Verify installation
Use the terminal in any directory to execute thego env command, and the following output will be output to illustrate Go language development The package has been installed successfully.
root@ububtu:~$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/feng/.cache/go-build" GOENV="/home/feng/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/feng/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" . . .
Linux Video Tutorial"
The above is the detailed content of Does linux support go language?. For more information, please follow other related articles on the PHP Chinese website!