How to install Go on CentOS 8

Go, often called golang, is a modern open source programming language created by Google that allows you to build real-time and efficient applications.

Many popular applications, such as Kubernetes, Docker, Prometheus and Terraform, are written in Go.

This tutorial explains how to download and install Go on CentOS 8.

1. Download and install Go on CentOS 8

At the time of writing this article, the latest version of Go is 1.13.4. When we download the installation package, please visit Go official download page, and check if there is a new version available.

Execute the following command on CentOS 8 to download and install Go:

  1. Use wget or curl tool to download Go binary installation package:
wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz
  1. Once the compressed package is downloaded, verify the check code of the compressed package by entering the following command:
sha256sum go1.13.4.linux-amd64.tar.gz

Please make sure that the hash value output by the sha256sum command is the same as the hash value of the download page.

692 d17071736f74be04a72a06dab9cac1cd759377bd85316e52b2227604c004c  go1.13.4.linux-amd64.tar.gz
  1. Use the tar command to extract the compressed package to the /usr/local directory:
sudo tar -C /usr/local -xf go1.13.4.linux-amd64.tar.gz

The above commands must be executed as root or a user with sudo privileges.

  1. By adjusting the $PATH environment variable to tell users where to find Go executable programs.

You can add the following lines to the /etc/profile file (system installation) or $HOME/.bash_profile file (current user installation).

export PATH=$PATH:/usr/local/go/bin

Save the file and use the source command to load the new PATH environment variable into the current shell session.

source ~/.bash_profile

that's it. At this point, Go has been installed on your CentOS system.

Two, test whether the installation is successful##

In order to test if your Go is installed correctly, we will set up a workspace and build a simple "Hello World" program.

  1. The location of the workspace is directly specified by the GOPATH environment variable. By default, it is set to $HOME/go. Run the following command to create this directory:
mkdir ~/go
  1. Create a new directory src/hello in the workspace:
nano ~/go/src/hello/hello.go

Paste the following code in the file:

package main

import"fmt"

func main(){
 fmt.Printf("Hello, World\n")}
  1. Switch to the directory ~/go/src/hello, and execute the go build command to compile the code:
cd ~/go/src/hello
go build

The above code will build an executable program called hello.

  1. Run this executable program by typing the following:
. /hello

If you see the following output, you have successfully installed Go.

Hello, World

Three, conclusion##

Now that you have downloaded and installed Go, you can start writing your Go code.

Recommended Posts

How to install Go on CentOS 8
How to install jdk1.8 on centOS7
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install TensorFlow on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Go on Ubuntu 20.04
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install Go on Ubuntu 20.04
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to install offline JDK1.8 on centos7.0
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8
How to install VirtualBox client extension on CentOS 8
How to install Docker CE on RHEL 8 / CentOS 8