The while loop in Golang

The while loop is a very important construct in general programming. But in Go, there is no loop called while. There are only for-loops. The while loops can be emulated using the for-loops in Go. So, here are some examples of how it can be done. How to construct while loop in Golang? The while […]

The while loop in Golang Read More »

The for-loop in Golang

Loops are an essential part of any programming language. It does a single task multiple times. In this post, we will be diving deeper with the for loops in Go. The for-loop syntax The for loop is one of the most common loops in programming. Almost every language has it. The for loop in Go

The for-loop in Golang Read More »

The switch statement in Golang

The switch statement is one of the most important control flow in programming. It improves on the if-else chain in some cases. Thus making it substantially easy to do the same task with much less code. In this post, we will see how we can use the switch statement in the Go programming language. What

The switch statement in Golang Read More »

The blank identifier in Golang

Sometimes, a programming language needs to ignore some values for multiple reasons. Go has an identifier for this. If any variable is declared but not used or any import has the same issue, the Go compiler throws an error. Golang blank identifier helps prevent that. What is the blank identifier? The blank identifier is the

The blank identifier in Golang Read More »

Type-casting in Golang

Sometimes we need to convert one data-type to another. In this post, we will go into detail about type-casting in the Go programming language. Types in Go There are many data-types in Go. The numbers, floating points, boolean and string. Number: int, int32, int64, uint32, uint64 etc Floating points: float32, float64, complex64, complex128 Boolean: bool

Type-casting in Golang Read More »

Type switches in Golang

A type-switch in Go is just like the switch statement but with types. In this post, we will go into details about the type-switches in Go. But first, we need to understand the switch statement. What is a switch statement? A switch statement is a control flow which checks for a condition to match and

Type switches in Golang Read More »

Type assertions in Golang

Type assertions in Go help access the underlying type of an interface and remove ambiguity from an interface variable. In this post, we will get a closer look at type assertions. What are type-assertions in Golang? Type assertions reveal the concrete value inside the interface variable. Below is an example showing the assertion. Type assertion

Type assertions in Golang Read More »

Interfaces in Golang

In general programming interfaces are contracts that have a set of functions to be implemented to fulfill that contract. Go is no different. Go has great support for interfaces and they are implemented in an implicit way. They allow polymorphism in Go. In this post, we will talk about interfaces, what they are, and how

Interfaces in Golang Read More »