“Go Language 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
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 it 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 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 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.
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.
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 here
To download Go packages use following syntax –
→ go get <github_url>
for ex. > go get github.com/gorilla/mux (fully qualified pkg name)
To know more about go commands type > go in cmd prompt
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 computer
The most popular IDE’s (Integrated Development Environment) used for Golang development are Eclipse , WebStorm ,atom.
We are going to use Eclipse IDE here
In the Eclipse , right click on Help Menu→ Eclipse Marketplace→ search for ‘Goclipse’ and install it.
After the installation,
Go to File Menu→ Go Project→ Enter Project Name and choose default location as your workspace location
Your project structure will be like this –
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
Here, you just need to click on Download button for each of these paths.
While downloading check the console
Now, your Go installation and configuration is done.
Make sure you do not miss a single step.
For more information on Golang refer below links –
As you are now all set with Golang, check out our next chapter on ‘Creating Your First Go Project‘
What’s on your mind? Tell us a little bit about yourself and your question, and we will be in touch with you within 12 hours
Free eBook on Telemedicine Platform Development: All About TelemedicineDownload Free eBook Now!