Linux does not support go language

May 29, 2023 pm 10:25 PM
linux go language

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.

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. It requires no dependencies due to its modular design and the compilation and conversion of code into a minimized binary form. Its code can be compiled on any platform (Windows, Linux, Mac OS, etc.) and can be compiled on any server and application.

Go language code can be directly compiled into binary executable files without using a virtual machine. The Go language has an independent linker and does not need to rely on the compiler and linker provided by any operating 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 view it on the Go language official website Looking at the installation package, the development package has two versions: 32-bit and 64-bit. You need to choose different versions according to the situation of the reader's computer.

Linux does not support go language

Copy the download link of the Go language development package. 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#
Copy after login

Use the wget command to download the Go language development package, as shown below.

<div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>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])</pre><div class="contentsignin">Copy after login</div></div><p>Use the tar command to decompress the Go language development package you just downloaded. </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>root@ububtu:/usr/local# tar -C /usr/local -xzf go1.13.4.linux-amd64.tar.gz</pre><div class="contentsignin">Copy after login</div></div><p>After successful decompression, a go directory will be added in the current directory. At this point, our Go language development kit has been installed. Use the cd command to enter the directory, and then execute bin/ You can use the go version command to view the current Go language version. </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>root@ububtu:/usr/local/go# bin/go version go version go1.13.4 linux/amd64</pre><div class="contentsignin">Copy after login</div></div><p><strong>Configure environment variables</strong></p><p>We need to configure 2 environment variables, GOROOT and PATH. </p><ul class=" list-paddingleft-2"><li><p>The value of GOROOT should be the current installation directory of the Go language: <code>export GOROOT=/usr/local/go

  • PATH In order to facilitate the use of Go language commands and Go program executable files, you need to append its value: export PATH=$PATH:$GOROOT/bin:$GOBIN

  • In order to facilitate future use, these environment variables need to be added to the profile file (~/.bash_profile or /etc/profile). If it is used by a single user, the environment variable can be added to the bash_profile file in the home directory. If used by multiple users, it needs to be added to the /etc/profile file. It is recommended to set environment variables in the /etc/profile file

    Use the vi /etc/profile command to open the profile file and add the environment variables to the end of the file.

    Linux does not support go language

    After the addition is completed, use the :wq command to save and exit.

    Then, use the 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 the go env command. The following output shows that the Go language development package has been successfully installed.

    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=""
    . . .
    Copy after login

    Tip: Only partial results are shown above.

    The above is the detailed content of Linux does not support go language. For more information, please follow other related articles on the PHP Chinese website!

    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

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

    VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

    Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

    The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

    How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

    Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

    vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

    vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

    How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

    To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

    Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

    Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

    laravel installation code laravel installation code Apr 18, 2025 pm 12:30 PM

    To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

    How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

    Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

    See all articles