A Short Brief on Go Programming Language!!!

Ankita Sharma
Catalysts Reachout
Published in
4 min readNov 3, 2022

Introduction

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 example., type inference (y := 0 is a valid declaration of a variable y of type float).

Why this “Go language”?

Because Go language is an effort to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing.

Beginning with Go Programming

There are various online IDEs such as The Go Playground, repl.it, etc. which can be used to run Go programs without installing.

For installing Go in own PCs or Laptop we need of following two software: Text editor and Compiler
Text Editor: Text editor gives you a platform where you write your source code. Following are the list of text editors:

  • Windows notepad
  • OS Edit command
  • Brief
  • Epsilon
  • vm or vi
  • Emacs
  • VS Code

Finding a Go Compiler: 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.

Note: Extension of source code file of go language must be .go

Go program structure

Every Go program must be included in a package. A standalone executable Go program must have a main function and must be included in the main package. The main function is the entry point of the execution. A standalone executable program is a Go program that can be built to an executable using go build command or ran using go run command.

package mainimport "fmt"func main(){
fmt.Println("Hello World!")
}

Explanation of the syntax of Go program:

  • Line 1: It contains the package main of the program, which have overall content of the program. It is the initial point to run the program, So it is compulsory to write.
  • Line 2: It contains import “fmt”, it is a preprocessor command which tells the compiler to include the files lying in the package.
  • Line 3: main function, it is beginning of execution of program.
  • Line 4: fmt.Println() is a standard library function to print something as a output on screen. In this, fmt package has transmitted Println method which is used to display the output.
  • Comment: Comments are used for explaining code and are used in similar manner as in Java or C or C++. Compilers ignore the comment entries and does not execute them. Comments can be of single line or multiple lines.

Single Line Comment:

Syntax:

// single line comment

Multi-line Comment:

Syntax:

/* multiline comment */

Advantages and Disadvantages of Go Language

Advantages:

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

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

. Quick Outcome- Its compilation time is very fast.

. Library- It provides a rich standard library.

. 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.

. 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.

Some popular Applications developed in Go Language!!

  • 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.
  • 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.
  • 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.

--

--