Steps for installing Go language on Linux system

  

Linux system The full name of Go language is golang, which is a programming development language. The Go language is characterized by open source, security, fast, and so on. There are a wide range of applications in Linux systems. This article will introduce the Linux system to install the Go language.

a, Ubuntu, Debian or Linux Mint installation Go language

to install Debian-based Linux distributions can use the apt-get command:

1 .sudo apt-get install golang

To view the Go language version of the current system installation you can use the following command:

1.go version

Since the Go code must be saved in the workspace (Workspace), so we have to create a workspace directory in the Home directory (eg ~/workspace) and define the GOPATH environment variable to point to this directory, which will be used by the Go tool to save and edit binaries.

1.mkdir ~/workspace

2.echo ‘export GOPATH=“$HOME/workspace”’ 》》~/.bashrc

3.source ~/.bashrc

Depending on the needs, we can use apt-get to install Go tools:

1.sudo apt-cache search golang

Second, Fedora, CentOS Or RHEL install Go language

Red Hat-based Linux distributions can be installed using the yum command:

1.sudo yum install golang

To view the current system installation The Go language version can use the following command:

1.go version

Next, create a workspace directory in the Home directory (for example, ~/workspace) and define the GOPATH environment variable to point to the directory. This directory will be used by the Go tool to save and edit binaries.

1.mkdir ~/workspace

2.echo ‘export GOPATH=“$HOME/workspace”’ 》》~/.bashrc

3.source ~/.bashrc

Third, according to different needs, we can use yum to install Go tools:

1, yum search golang

Manually install Go language for Linux

Since the Linux source you use is not the same, it is not necessarily the latest version or the required version of the Go language pack, so let's talk about how to manually install the specified version.

Golang Download

2. Unzip the binary to the /usr/local directory

1.sudo tar -xzf go1.4.2.linux-xxx.tar.gz -C /usr/local

3. Use vi to add the following to the environment variable configuration file /etc/profile:

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

4, check the Go language version

1.go version

5, define the GOPATH environment variable to the workspace directory

1.export GOPATH=“ $HOME/workspace

The above is the step of installing the Go language on Linux. It should be noted that the installation of Go language in different versions of Linux system will be different, so it can't be confused.

Copyright © Windows knowledge All Rights Reserved