Index of GoLang Resources
- How to install Go? | Chapter 1 |
- Creating Your First GoLang Project |Chapter 2 |
- GoLang Language Fundamentals | Chapter 3 |
- Control Flow in GoLang | Chapter 4 |
- GoLang Data Structures | Chapter 5.1 |
- GoLang Data Structures | Chapter 5.2 |
- GoLang Concurrency | Chapter 6 |
- Error Handling in GoLang | Chapter 7 |
- Common Utilities in GoLang Project | Chapter 8 |
- GoLang Database/SQL | Chapter 9 |
- GO with GORM | Chapter 10 |
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 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:
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.
Features of Golang
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.
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 –
Powerful Standard Library
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
To install Go, we need to go through the below steps.
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.
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.
You can Download the Go lang binary release. Download Golang distribution based on 32bit and 64bit OS
Certain folder structure for Go development
Create a Project Folder having a name where your project will reside
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)
To download Go packages use the following syntax –
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→
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
Most popular IDE’s (Integrated Development Environment) used for Golang development are Eclipse, WebStorm, atom.
We are going to use Eclipse IDE here
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.
After the installation,
Step 1) Go to File Menu→Go Project→Enter Project Name and choose default location as your workspace location
Your project structure will be like this –
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
Step 3) click on the Download button for each of these paths.
While downloading check the console
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.