The Go programming language was created in 2007 at Google. Many projects are created in Golang including Docker, Kubernets, Gogs, InfluxDB and others.
The Go language can be used on various operating systems including Linux systems, Windows, Mac OS X and FreeBSD. You can even run it online, from your browser.
The Go language is a brand new static type development language with automatic garbage collection, rich built-in types, function multiple return values, error handling, anonymous functions, concurrent programming and reflection, and features such as simplicity, security, concurrency, and open source.
If you have a package manager, you can install it from a repository.
Ubuntu / Debian Linux
Install a set of tools to run Go programs.
apt-get install golang-go
CentOS 7 / Redhat Linux
If you use Redhat or CentOS, you can use yum to install go
yum install golang golang-godoc golang-vet golang-src golang-pkg-linux-amd64 -y
Installing under Windows systems, download
You can choose the local installation directory:
D:\Go, add the
D:\Go\bin directory to the PATH environment variable.
$GOPATH=D:\goproject and $GOROOT=D:\Go\.
On CMD, enter
go version, which shows that the go run environment has been successfully installed:
$GOPATH allows multiple directories, when more than one directory is available, attention to separators, multiple directories when Windows is a semicolon; the packages that go get are stored in the first directory by default when more than one $GOPATH is available.
$GOPATH catalog convention has three subdirectories
src storage source code (such as .go. c .h .s, etc.) executes the current working path of commands such as
go install, etc. according to Go default (that is, executing the above command under this path).
The intermediate file generated when the pkg compiles, such as:
.a the executable file that is generated after the bin compilation, can then try the code compilation to run.
UNIX/Linux/Mac OS X, and using the source code installation method under the FreeBSD system:
Download source package:
Extract the downloaded source package to the
tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz
/usr/local/go/bindirectory to the PATH environment variable:
For other systems, you can run a manual install.
Running go online
You can run golang programs online on the Go Playground.
On that page simply type your code and click run.
To check the current version of Golang, you can use the command.
[[email protected] ~]# go version
This command returns something like:
$ go version
If you get this output, Go has been installed successfully.
Leave a Reply