How to install go?

How to install go?

how to install go

 

This is a series of blogs on Golang in which we will be narrating everything from an introduction to GO, Installing Go till Developing Go application on Aws server .in a series of 10 chapters which will be uploaded every week.

Let us start with the first chapter !!!!

 

What is GO?

 

“Go will be the server language of the future.” — Tobias Lütke, Shopify

It is a Free and Open Source programming language created at Google Inc. in 2007 by Ken Thompson (B, C, UNIX, UTF-8), Rob Pike(UNIX, UTF-8) and Robert Griesmer (HotSpot, JVM)

Go is created by leading tech giant Google. It is designed by Google to solve their problems of supporting scalability and effectiveness. Those are the issues you will face while creating your own servers.

Go (Golang) is Procedural, Imperative, Modular, Object-Oriented, Statically typed, Garbage Collected, Compiled programming language with syntax similar to the family of  C languages (C, C++, C#, Java, JavaScript) & CSP style concurrency features. Programs are created using packages, for efficient management of dependencies. Go programming implementation use a traditional compile and link model to generate executable binaries. The Golang announced in 2009 and used in some of Google’s production system.

Go Program can be in length from 3 lines to millions of lines and it should be written into one or more files with the extension “.go”.  For example, hello.go.

You can use “vi”,”vim” or any other text editor to write your go program into a file

 

Go is fast:

  • to learn

  • to develop

  • to compile

  • to deploy

  • to run

 

 

Bonus Advantages:  

  • Golang has the speed of compiled language, but the feel of an interpreted language

  • Golang can make connections with thousands of users with a single instance only.

 

Valuable resources of Golang (by Todd McLeod)

 

Books on Golang

 

Features of Golang

Multicore processing:

Most of the programming languages like Python, Java supports multithreading but the problem is with concurrent execution, thread- locking, race conditions, and deadlocks. This makes hard to create a multithreading application.

For example, when we are creating a new thread in java it will consume approx 1MB heap and for multiple thread creations, it will put tremendous pressure on a heap and so will cause JVM not responding or shutdown.

So, Golang has developed by keeping this concurrency feature in mind. Go has goroutines instead of threads which consumes 2KB of memory from the heap.

goroutines have faster startup than thread.

 

MicroServices Support:

 

Today all applications have no. of external services like databases, queues, caches. Go uses async I/O so that application can work with any no of services without blocking web request.

Other Features Include –

  • Super performance

  • Clean Syntax

  • Garbage Collected

  • Concurrency

  • Powerful Standard Library

  • Open Source

  • Portable

  • Safe

  • It compiles fastly without makefiles, integrates with Git for distributed package management, and formats code with gofmt.

Go based system now runs on 400 servers,200+ million real-time connections & 10 billion messages daily.

Many big companies are using Golang for their projects

  • Google

  • DropBox

  • SoundCloud

  • Docker

  • Cloudflare

  • BBC

Features of Golang

 

Installing Go

To install Go, we need to go through the below steps.

Introduction

For Windows, we need to use commands from Git Shell i.e. Terminal Emulator for distributed package management (optional). So we need Terminal Emulator for that.

Terminal Emulator-Git

Download and install git for Windows to download go packages. We can also use the command prompt for the same. Now open it and test it using some basic terminal commands.

Installation Insights

Download Golang:

You can Download the Go lang binary release. Download Golang distribution based on 32bit and 64bit OS

Go workspace

Certain folder structure for Go development

Create a Project Folder having a name where your project will reside

For example,

 

E:\golangdemo  (Name of my Workspace)

                                  bin folder (binary exe file of project)

                                   pkg folder (.a Archive file à precompiled pkg file)

                                  src folder (Source code files)

                                            github.com folder(downloaded dependencies)

                                            golang.org folder (downloaded dependencies)

 

Search for go packages

To download Go packages use the following syntax –

→go get  

for ex. > go get github.com/gorilla/mux (fully qualified pkg name)

To know more about go commands type > go in cmd prompt

Environment Path Variables-Windows

After creation of Go workspace set the Path variable of Go installation by following these steps –

Right, Click on MyComputer/ThisPC→Properties→ AdvancedSystem Settings →EnvironmentVariables→New→

 

 

Search Package

 

Here you need to set GOPATH and GOROOT for both User variables and System variable.

GOPATH→ Your workspace path

GOROOT→ Installed Path of GO

To check environment path variables use below command in cmd prompt –

→   env path variable stores the path to some location of a computer

Development Environment

Most popular IDE’s (Integrated Development Environment) used for Golang development are Eclipse, WebStorm, atom.

We are going to use Eclipse IDE here

  • Eclipse

  • GoClipse plugin

  • Creating new Go Project || Package || Library

How to download and install Goclipse plugin to your eclipse –

In the Eclipse, right click on Help Menu→ Eclipse Marketplace→ search for ‘Goclipse’ and install it.

go root

After the installation,

Step 1) Go to File Menu→Go Project→Enter Project Name and choose default location as your workspace location

Go Project Menu

 

Your project structure will be like this –

Project Explorer

 

Step 2) Go to windows menu of eclipse→select Preferences→choose Go→Tools→Click on Download and it will download the dependencies like gocode, guru, godef, gofmt and click apply

Windows Eclipse

 

Step 3) click on the Download button for each of these paths.

 

download eclipse

 

While downloading check the console

 

console

 

Step 4) Now your Go installation and configuration is done.

Make sure you do not miss a single step.

For more information on Golang, you can refer below links –

https://golang.org/doc/code.html

https://golang.org/doc/effective_go.html

 

Conclusion:

RemotePanda is a personalized platform for companies to hire remote talent and get the quality work delivered from the city Pune. The resources in our talent pool are our close network connections. While connecting them with you, we make sure to manage the quality, growth, legalities, and the delivery of their work. The idea is to make remote work successful for you. Get in touch with us to learn why RemotePanda is the best fit solution for your business requirements.

Comments are closed.