Introduction to Object Oriented Programming (OOP) in Golang

When we talk about programming, we usually mean writing a bunch of functions that modify and interact with some data. Object Oriented Programming (OOP) is a programming model that instead focuses on “objects” that contain data and and have some relevant functions attached to them. Object Oriented Programming has four pillars: Inheritance, Encapsulation, Polymorphism, and Abstraction. In this blog, we’ll take a look at how you can implement each of them in Golang with examples. Some basic idea about OOP is recommended, but if not, I will be giving a brief introduction to what all the four pillars mean. ...

December 16, 2024 · 9 min · Arsh Sharma

Channels In Golang

This is the final post in my “Do You Concur?” series. If you’ve not checked the other two out it is highly recommended you do that before reading this one. With that out of the way let’s get started! What Are Channels? A channel in Go can be best understood by comparing it with a box. It is a box where goroutines can put and take out the data. So essentially channels help your goroutines to share data. One goroutine can send a value into the channel and another goroutine can receive those values. A very simple code snippet demonstrating this is: ...

May 27, 2021 · 3 min · Arsh Sharma

Race Conditions In Golang

This post is the second in my series of articles on Concurrency in Go. In this post, we’ll understand what a race condition is, the why and how of it, and finally, we see some code that creates a race condition, and then we will learn to fix that race condition with the help of Mutexes. So let’s get started! The What, Why And How Of A Race Condition A race condition in Go occurs when two or more goroutines have shared data and interact with it at the same time. This is best explained with the help of an example. ...

May 24, 2021 · 6 min · Arsh Sharma

Concurrency In Golang

I recently started learning more about concurrency in golang and so as with other things I learn, I decided to write about it. This article will be a part of a short series I plan to write about concurrency in Go. So let’s get started! Concurrency Vs Parallelism Before we start looking at some code, I think it would be better to know what concurrency actually is. But even before we do that let us first talk about parallelism because it is a word that often comes up when talking about concurrency. ...

May 19, 2021 · 5 min · Arsh Sharma

Creating A CLI In Golang

This is technically the first post on my blog so I’m pretty excited to write this one 😄 For the last few months, I’ve been working on depstat, which is a command-line tool to analyze dependencies, as part of my CNCF Internship. I’ve had a blast working on this especially because of the welcoming community. depstat is going to be used to evaluate dependency updates to Kubernetes and has been written in Go so I thought about sharing some stuff I learned :D ...

April 17, 2021 · 5 min · Arsh Sharma