How to install Golang language

PHPz
Release: 2023-04-24 17:00:38
Original
507 people have browsed it

Golang (also known as Go language) is a programming language developed by Google. The original design is to improve the operating efficiency and development efficiency of programs. This article will introduce how to install the Golang language.

  1. Preparation
    Before starting the installation, you must ensure that your operating system has the appropriate version of Golang installed. If it is not installed, you can download the correct version of the binary file from the Golang official website.
  2. Download Golang
    You can find binary file downloads for various platforms on the Golang official website. Here we choose binaries suitable for Linux systems.

Enter the following command in the terminal window to download the Golang binary for Linux systems.

$ wget https://golang.org/dl/go1.15.3.linux-amd64.tar.gz
Copy after login
  1. Install Golang

After the download is complete, we need to decompress and install the Golang file. To unzip the files you can use the following command:

$ tar -C /usr/local -xzf go1.15.3.linux-amd64.tar.gz
Copy after login

This will create a subdirectory named "go" under the /usr/local directory and place all unzipped files here Under contents.

Next, we need to add the path of the Golang binary file to the system environment variable. The path can be added to the environment variable using the following command:

$ echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
$ source ~/.bashrc
Copy after login
  1. Testing Golang

After Golang is installed, we can test to make sure it was installed successfully. Enter the following command in the terminal window:

$ go version
Copy after login

If everything is fine, you should see the following output:

go version go1.15.3 linux/amd64
Copy after login
  1. Start using Golang
    Now you have successfully installed Golang, It's time to start using it. You can use any text editor to write source code. After saving the file, name it main.go and compile it using the following command:
$ go build main.go
Copy after login

This will generate an executable file main in the current directory.

Now, you can use the following command to run the program:

$ ./main
Copy after login

At this point, you have successfully installed Golang and written your first program. Happy programming!

The above is the detailed content of How to install Golang language. 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!