What is Golang and How to Install It

Sayan Mondal
Level Up Coding
Published in
5 min readNov 15, 2019

--

Go, which is also commonly referred to as Golang, is a programming language that was created to find the optimal tradeoff between performance, control, and developer experience. Its development began in 2007 at Google, and the first public release was out by 2009.

According to golang.org:

Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software.

History

Let’s go a few years earlier, the creator of the language Robert Griesemer, Rob Pike, and Ken Thompson were lead developers at Google. Their main aim was to exclude the “extraneous garbage” from languages like C and C++ while still being able to cover the main challenges while working with the company’s intricate systems.

The developers of this language were primarily motivated by their shared hatred for C++, leading them to create a language that had a mix of different programming elements and concepts as well.

For example:

  • Static typing and run-time efficiency (like C++)
  • Readability and usability (like Python or JavaScript)
  • High-performance networking and multiprocessing

Why Learn Golang?

When you write Go code, you have to be very careful about the indentations and the number of spaces used. The language requires that none of its declared variables or imported libraries are unused, and all return statements are compulsory. The yields the following characteristics:

  • Super easy to learn
  • An easy-to-use interface
  • Lots of job scope/opportunities out there
  • A real language used to solve real problems
  • You can use it for web development
  • Many of current top-notch applications are being written in Go

According to many surveys on “What is the language of people’s choice?” the results are astonishing as Golang easily outperforms a lot of other programming languages.

Go Installation on Windows

To install Go in your system, you need to follow this step by step guide. Doing this will ensure that you have successfully installed GoLang in your system.

Step 1: The first thing you’ll need is a Git version control system (download) since with Go you’ll use a lot of open-source repositories.

Step 2: Go to golang.org and download the latest 64-bit Go MSI distributable and install it. To make things simpler you can keep the default installation path at C:\Go

Step 3: Now that you have installed Go in your system, to be able to actually use it you need to make sure that the Go binaries (typically in Your_Installed_Directory:\Go\bin) have successfully been added to your environment path variables.

To check that, open your environment variables. A quick way to get there is simply by typing ‘env’ in your start menu and selecting the first option.

Then just simply click on the Environment Variables… button on the bottom right corner.

Open Path under User Variables and there should be a path specified as %USERPROFILE%\go\bin, if not then add the same by clicking on New. To put it simply, this step ensures that your Go binaries are reachable by your system.

To confirm that you have done all the above steps successfully open Command Prompt as an Administrator and type go version:

Go Version

You should see the current version of Go that is running in your system.

Time to set up your Workspace

Any Go project should have three very important files in your root directory.

bin\
pkg\
src\

For me, I want to set my project directory in D:\Projects\Go. Feel free to choose your own destination location. Inside of your project folder, create these three folders.

Project Structure

Now the most important step, you have to create your GOPATH environment variable. This will be the system’s go-to location whenever you run a Go project.

Open the Environment Variables box again and select New under System variables

Set the variable name to GOPATH and the value to your Go workspace path.

To check that you have successfully set your GOPATH open Command Line as an Administrator and type echo %GOPATH% and your project workspace should be highlighted.

echo workspace

Well done, You’re almost there. Now comes the fun part.

Write your first Hello World program

Because Go heavily relies on open source, let’s build our first program without even writing a single line of code.

Open the command line and type the following command to pull the open-source repository from GitHub:

go get github.com/golang/example/hello
%GOPATH%/bin/hello

If you’re successful, you’ll see the following result:

Hello World in GoLang

Voila

Go and Rock the world now.

🤩 ✌️

--

--

Software Engineer 🌟 • A coffee lover ☕ and explorer 🌏 In my free time I like to write Code and help the community out. 💻