top of page

Go Programming Language



Go is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports environment adopting patterns alike to dynamic languages. For eg., type inference (y := 0 is a valid declaration of a variable y of type float).


Text Editor

You will require a text editor to type your programs. Examples of text editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS, and vim or vi.


The name and version of text editors can vary on different operating systems. For example, Notepad is used on Windows, and vim or vi is used on Windows as well as Linux or UNIX.


The files you create with the text editor are called source files. They contain program source code. The source files for Go programs are typically named with the extension ".go".


Before starting your programming, make sure you have a text editor in place and you have enough experience to write a computer program, save it in a file, compile it, and finally execute it.


The Go Compiler

The source code written in source file is the human readable source for your program. It needs to be compiled and turned into machine language so that your CPU can actually execute the program as per the instructions given. The Go programming language compiler compiles the source code into its final executable program.


Go distribution comes as a binary installable for FreeBSD (release 8 and above), Linux, Mac OS X (Snow Leopard and above), and Windows operating systems with 32-bit (386) and 64-bit (amd64) x86 processor architectures.


History:

Go was designed at Google in 2007 to improve programming productivity in an era of multicore, networked machines and large codebases.The designers wanted to address criticism of other languages in use at Google, but keep their useful characteristics:

  • static typing and run-time efficiency (like C),

  • readability and usability (like Python or JavaScript),

  • high-performance networking and multiprocessing.


Syntax:

A Go program basically consists of the following parts −

  • Package Declaration

  • Import Packages

  • Functions

  • Variables

  • Statements and Expressions

  • Comments

Let us look at a simple code that would print the words "Hello World" −

package main

import "fmt"

func main() 
{
/* This is my first sample program. */
   fmt.Println("Hello, World!")
}


Advantages:

  1. Flexible- It is concise, simple and easy to read.

  2. Concurrency- It allows multiple process running simultaneously and effectively.

  3. Quick Outcome- Its compilation time is very fast.

  4. Library- It provide a rich standard library.

  5. Garbage collection- It is a key feature of go. Go excels in giving a lot of control over memory allocation and has dramatically reduced latency in the most recent versions of the garbage collector.

  6. It validates for the interface and type embedding.


Disadvantages:

  1. It has no support for generics, even if there are many discussions about it.

  2. The packages distributed with this programming language is quite useful but Go is not so object-oriented in the conventional sense.

  3. There is absence of some libraries especially a UI tool kit.



Applications

  • Docker: a set of tools for deploying linux containers

  • Openshift: a cloud computing platform as a service by Red Hat.

  • Kubernetes: The future of seamlessly automated deployment processes

  • Dropbox: migrated some of their critical components from Python to Go.

  • Netflix: for two part of their server architecture.

  • InfluxDB: is an open-source time series database developed by InfluxData.

  • Golang: The language itself was written in Go.



Features:

  • Language Design: The designers of the language made a conscious purposeful to keep the language simple and easy to understand. The entire detailing is in a few pages and some interesting design decisions were made through Object-Oriented support in the language.Towards this, the language is opinionated and recommends an idiomatic way of achieving things. It prefers Composition over Inheritance. In Go Language, “Do More with Less” is the mantra.

  • Package Management: Go merges modern day developer workflow of working with Open Source projects and includes that in the way it manages external packages. Support is provided directly in the tooling to get external packages and publish your own packages in a set of easy commands.

  • Powerful standard library: Go has powerful standard library, which is distributed as packages.

  • Static Typing:Go is static typed language. So, in this compiler not just work on compiling the code successfully but also ensures on type conversions and compatibility. Because of this feature Go avoid all those problems which we face in dynamically typed languages.

  • Testing Support: Go provides us the unit testing features by itself i.e., a simple mechanism to write your unit test parallel with your code because of this you can understand you code coverage by your own tests. And that can be easily used in generating your code documentation as an example.

  • Platform Independent: Go language is just like Java language as it support platform independency. Due to its modular design and modularity i.e., the code is compiled and is converted into binary form which is as small as possible and hence, it requires no dependency. Its code can be compiled in any platform or any server and application you work on.



The Tech Platform

0 comments
bottom of page