golang liunx installation

WBOY
Release: 2023-05-16 17:48:39
Original
340 people have browsed it

Go (also known as Golang) is an open source programming language developed by Google. It combines the efficiency of statically typed compiled languages ​​with the ease of use of interpreted languages. The core concept of Go language is to take into account both efficiency and openness.

Linux is a free and open source operating system. It is one of the most famous server operating systems in the world and has a wide range of applications. In this article, we will introduce how to install the Go language environment on the Linux operating system.

Installation method:

  1. Download the Go language installation package

Use a browser to enter the Go official website: https://golang.org/dl/, Select the appropriate version to download. In the following installation process, we will use the go1.14.2.linux-amd64.tar.gz version for demonstration.

  1. Extract the installation package

Use the terminal to enter the download directory and decompress the downloaded Go language installation package:

tar -zxvf go1.14.2.linux-amd64.tar.gz
Copy after login

This will be in the current directory Create a folder named go, which contains all the files needed to run the Go language.

  1. Configure environment variables

Set the GOROOT environment variable to indicate the installation path of the Go language:

sudo nano /etc/profile
Copy after login

Add the following content at the end of the file:

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

Save and exit.

  1. Take effect immediately

Use the following command to make the environment variables take effect immediately:

source /etc/profile
Copy after login
  1. Test installation

Enter the following command:

go version
Copy after login

If the Go language version information is output, the installation is successful.

  1. Set GOPATH

GOPATH is the Go language workspace path, used to specify the location of the working directory. You can set GOPATH to any folder path, for example:

mkdir $HOME/go
export GOPATH=$HOME/go
Copy after login

Save and exit. Finally, synchronize the modifications:

source ~/.bashrc
Copy after login

At this point, we have successfully installed the Go language environment, configured the environment variables and GOPATH, and can happily develop Go language.

Conclusion:

Through the above simple steps, we have successfully installed the Go language environment on the Linux system and completed the configuration of environment variables and GOPATH. At this point, we can start our own development journey. If you have not started learning the Go language, I recommend you to attend some relevant training courses. Mastering the Go language will bring great help to your career development.

The above is the detailed content of golang liunx 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!