CentOS 6 is an open source operating system built on the Red Hat Enterprise Linux (RHEL) source code. It is a very stable operating system and is widely used in servers and cloud computing platforms. Golang is a high-performance programming language known for its concurrent programming and performance optimization. This article will introduce how to install Golang on CentOS 6.
EPEL repository (Extra Packages for Enterprise Linux) is a Fedora-based repository that provides many software packages that CentOS does not have. To install the EPEL repository, use the following command:
sudo yum install epel-release
Before installing Golang, you need to install some dependencies. Install these dependencies using the following command:
sudo yum install curl git mercurial make binutils bison gcc
Now you can start downloading and installing Golang. Visit https://golang.org/dl/ to download the latest version for your operating system.
cd /tmp curl -O https://dl.google.com/go/go1.16.3.linux-amd64.tar.gz
Extract the file:
tar -xvf go1.16.3.linux-amd64.tar.gz
Move the decompressed folder to the /usr/local directory:
sudo mv go /usr/local
Next, configure the environment variables. Open the ~/.bashrc file:
vi ~/.bashrc
Add the following lines at the end of the file:
export GOPATH=$HOME/go export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
Save and close the file. To make the changes effective:
source ~/.bashrc
Now you can verify that Golang was successfully installed. Use the following command to run the Hello World program:
echo 'package main; import "fmt"; func main() { fmt.Println("Hello, world") }' > hello.go go run hello.go
If "Hello, world" is output, the installation is successful.
On CentOS 6, Goland is one of the most commonly used Go IDEs. Follow the steps below to install Goland:
a. Visit https://www.jetbrains.com/go/download to download the latest version of Goland.
b. Move the files to the /opt directory using the following command:
sudo tar -C /opt -xzf <下载文件名>.tar.gz
c. Create an executable file:
cd /opt/<下载文件名>/bin ./<下载文件名>.sh
Now, you have successfully installed Goland.
Summary
It is not difficult to install Golang on CentOS 6. You just need to install the EPEL repository, download and install Golang, configure environment variables, verify the installation is successful, and finally install the Go IDE for Golang.
Golang is a powerful programming language with extremely high performance and concurrency processing capabilities. If you are developing a Golang application on CentOS 6, the steps provided in this article can help you get started quickly.
The above is the detailed content of centos 6 install golang. For more information, please follow other related articles on the PHP Chinese website!