Golang: overview

Golang: overview
Written by Nilima PaulDecember 7, 2021
12 min read
Golang
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Nilima Paul

Data Team

This article explains to you the overview of Golang and its advantages and disadvantages.

what is Golang?

Go was originally designed at Google in 2007. At the time, Google was growing quickly, and code being used to manage their infrastructure was also growing quickly in both size and complexity. Some Google cloud engineers began to feel that this large and complex codebase was slowing them down. So they decided that they needed a new programming language focused on simplicity and quick performance. Robert Griesemer, Rob Pike, and Ken Thompson designed Go.

Go became an open-source project and was released publicly in 2012. It quickly gained a surprising level of popularity and has become one of the leading modern programming languages.

blogpost

How Does Struct Work in Go language?

To comprehend the working of the struct information type in the go language first we ought to comprehend the reason why we want this, assume in the event that we needed to characterize a few subtleties of worker and inside that subtleties, you needed a consistently same name and information type each quality like name of the representative, compensation, and address of the worker. So in such cases, we can not utilize basic factors as everybody will attempt to utilize the various names and types. So when we will characterize the struct type with fixed name and information kind of each trait whoever will utilize these properties they need to utilize similar name and information types elas it won't work. It's functioning we can characterized in the couple of steps.

  • It works like any simple class of other languages, or we can say it is a simple light weight class.
  • We can use these struct types of data as the composition, but we can not use them as an inheritance.
  • Once we define or write type, the compiler expects the name of the variable.
  • Once we define the name of the variables we can give the name of the attributes along with data types of all attributes of them.
  • Whoever will try to use these struct data types of the variables they can only use those variables which we have defined inside the struct data types.
  • For example, if we have an address struct and inside the address, we can define the variables like the name of the city as string data type, Pin code as int variable, etc. And the one who wants to use struct they can initialize the city as the string name and Pin code as the integer value.

Advantages

Performance(Machine code)

GoLang is a compilation language which can be compiled to machine code and the compiled binary can be directly deployed to target machine without extra dependency. The performance is better than those interpreted languages.

Dynamic language feel

GoLang is a static language but it gives a feeling of dynamic language to developers. As a static language, lots of hidden issues can be detected when doing the compilation, especially syntax errors. Also there are lots of packages available for developer to use and it's very easy to import them during development, this makes us less worried about its capability and makes us feel like we are dealing with a dynamic language.

Concurrency support

This is probably the most praised feature of GoLang. It supports concurrency since it's born. It can fully utilize multi core capability. GoLang uses goroutine to achieve concurrency and it provides a very elegant goroutine scheduler system which makes it easy to spawn millions of goroutines. The stack usage can dynamically expand/shrink as well which makes the memory usage more smart. This is different from Java thread which normally allows only thousands of threads to be created. For more comparison, please check out Russell Cohen's article Why you can have millions of Goroutines but only thousands of Java Threads.

Built in runtime with GC support

Though its GC is not perfect, it can fulfill most of requirements about garbage collection. For detailed explaination about GoLang GC, check out Getting to Go: The Journey of Go's Garbage Collector.

Easy to learn

GoLang's authors all have C background, GoLang comes with gene of C. There are 25 keywords but with abundant expression power. It can support almost all features seen in other languages such as inheritance, overloading, object etc.

Tool chain

There are lots of easy to use built-in tools which help developers write maintainable and readable code. Efficiency is largely improved. These include gofmt, goimport etc. They can make our code look standardized and ease the work of review a lot.

Native C support

You can embed C code in a Go program so that you can use lots of powerful C libraries.

Disadvantages

Lack of frameworks

There is no major framework for GoLang developers. There is in other languages though. Ruby has Ruby on Rails, Python has Django and PHP has Laravel.

Error handling

Go programs requires function to return error if there might be error expected. This may cause problem where the track of the error is lost which leads to missing useful error handling logic. There are tools which can help detect this kind of miss such as errcheck and megacheck. But they are more like workarounds. Also developers need to write lots of if blocks to check error and handle it which makes the code less clean.

Package management

Package management in Go is not perfect, neither. By default, it cannot create a dependency tree with fixed package version, this means the build created may be based on different version of packages when building at different time. In contrast, Python, NodeJS(npm) and Ruby all have relative well maintained package management system. For example, in a Ruby on Rails project, you can have a Gemfile file which defines the dependencies and their dependent versions which means the same version of package would be used to create a new build even in the future some of them have later updates.

Generics support

Unlike other languages, there is no generics support until now and the problem with that is many repeated codes need to be written for the same type operations but just with different data types. This drawback is apparent for those algorithm implementation or common function support like getting max or min of two numeric values. There is max/min function for float64 but no same functions for int. Also some data structures cannot be implemented easily as well with lacking of generics support. Fortunately, there is generics support in the future Go 1.18 release.

There are other advantages and disadvantages of GoLang, let embrace them and deal with them smartly.

Conclusion

From this instructional exercise we took in the essential idea of the struct of the go language, we found out with regards to the working and punctuation of the struct type. We center around the different instances of the struct which elaborate and uncovered the significant realities about the struct.

Golang
overview
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Was this blog helpful?
You must be Logged in to comment
Code Block
Nilima Paul
Data Team
117 Blog Posts
0 Discussion Threads
Trending Categories
15
Software39
DevOps45
Frontend Development24
Backend Development20
Server Administration17
Linux Administration24
Data Center24
Sentry24
Terraform21
Ansible29
Docker28
Penetration Testing14
Kubernetes16
NGINX19
JenkinsX17
Recommended Blogs
1
Techiio

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

facebooklinkdeintwitter

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Copyright techiio.com @2020 Kolkata, India
made with by Abhishek & Priyanka Jalan
Copyright techiio.com @2020
made with by Abhishek & Priyanka Jalan