centos 6 install golang

PHPz
Release: 2023-05-13 10:23:07
Original
552 people have browsed it

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.

  1. Install EPEL repository

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
Copy after login
  1. Install Golang

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
Copy after login

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
Copy after login

Extract the file:

tar -xvf go1.16.3.linux-amd64.tar.gz
Copy after login

Move the decompressed folder to the /usr/local directory:

sudo mv go /usr/local
Copy after login

Next, configure the environment variables. Open the ~/.bashrc file:

vi ~/.bashrc
Copy after login

Add the following lines at the end of the file:

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

Save and close the file. To make the changes effective:

source ~/.bashrc
Copy after login

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
Copy after login

If "Hello, world" is output, the installation is successful.

  1. Install Go IDE

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
Copy after login

c. Create an executable file:

cd /opt/<下载文件名>/bin
./<下载文件名>.sh
Copy after login

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!

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