Golang is an open-source programming language that is designed to be simple, reliable, and efficient. Golang was developed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It was built to improve programming efficiency for large-scale software engineering projects.
#1. What is Golang and What are its Benefits?
Golang is compiled, statically typed, has automatic memory management, and uses a garbage collector to manage memory. The compiler provides warnings when the programmer writes potentially erroneous code so it is easier for programmers to write faster code without worrying about making mistakes that are difficult to find later on down the road.
This can help developers work more quickly since they don't have to worry about writing code that crashes due to errors or bugs that occur because of typos.
Golang has built-in language support for concurrency and garbage collection. Concurrency is the ability for a program to make progress on more than one task at a time, and this is made possible by Go's simple syntax and clean design which allows tasks to be quickly executed without complicated multi-threaded programming.
#2. Are there any projects that use Golang?
This is a list of some powerful open-source projects that have been created with Go:
Docker is an open-source engine that automates the deployment of any application as a lightweight, portable, self-sufficient container that will run virtually anywhere.
Kubernetes is an open-source platform for managing containerized applications across multiple hosts and providing basic mechanisms for service discovery and configuration sharing.
InfluxDB is an open-source distributed database used as a backing store for any use case involving large amounts of timestamped data, including DevOps monitoring and analytics.
#3. How to Install Golang On Linux?
.Install GoLang from the official package
This is the recommended way to install GoLang in Linux. Before we start, we need to download and save the official Golang release:
After that we will use tar command to extract it:
tar xvzf go1.3.src.tar.gz
GoLang will be installed under /usr/local directory (if it doesn't exist already).
We need to add the path of bin folder in our shell rc file (~/.bashrc or ~/.bash_profile) so we can access Golang programs easily later on:
Now we can check if our installation was successful by typing this in the shell terminal:
➜ go version go version go1.16.3 gccgo (GCC) 11.1.0 linux/amd64
As you can see, it will return with go version x.x.x , which means Golang is successfully installed. GoLang uses GOPATH environment variable to find where to install its program binaries, libraries, and documentation files for the current user, so let's create a new folder in our home directory called ‘gopath'.
After that we need to add it into our shell rc file (~/.bashrc or ~/.bash_profile):
You might also want to update your path variable in order to have access to Golang binaries through the terminal.
That should be it. Now type go version again in the shell to make sure that Golang is successfully installed and can access necessary files for its work properly.
. Installing Golang using the package manager
We are going to install GoLang using package managers.
This brings up two questions:
Why not use official packages provided by Golang? Is this safe?
It turns out, you can't always use official packages, especially if you want to install the latest release of Golang. Official binaries made for one specific Linux distribution may not run on other distributions because of incompatibilities between them. You could even hit some dependency problems while trying to install Golang via official packages.
That's why it is recommended to install Golang using package managers if you are not satisfied with the official packages provided for your distribution.
Debian/Ubuntu users can use the following command line to install Golang:
➜ sudo apt-get install Golang
RHEL Linux users can use this command to install GoLang:
➜ sudo yum install Golang
If everything went well, we should be able to check the Golang version now by typing in the shell terminal:
➜ go version
#4. What is the best Editor to use to program in Golang?
If you are looking for a good editor to code in Golang, then please take a look at the following list (most of these editors come for free):
- Visual Studio Code
- Sublime Text
In this lesson, you've been introduced to the fundamentals of setting up Go on your Linux system.
Because it is simple to use and purpose-built, Go is an excellent language to learn. It's also gaining traction fast and receives support from Google. Many organizations and companies like Docker are adopting Go.
For additional information on Go usage and development, you can always go to Golang official website: https://golang.org/
Thank you for reading! If you like this article don't hesitate to share it with your friends as well as comment below as I love getting feedback from the community 🙂