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.
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
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
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
After Golang is installed, we can test to make sure it was installed successfully. Enter the following command in the terminal window:
$ go version
If everything is fine, you should see the following output:
go version go1.15.3 linux/amd64
$ go build main.go
This will generate an executable file main in the current directory.
Now, you can use the following command to run the program:
$ ./main
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!