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 »

Variadic functions in Golang

In many cases, multiple parameters are needed to be passed in a function. Sometimes we know how many and other times we don’t. Golang variadic function applies to the second case where we don’t know how many arguments could be passed when calling that function. What are variadic functions in Golang? Variadic functions are just

Variadic functions in Golang Read More »

Anonymous Functions in Golang

There can be functions that don’t need a name in order to be defined. These are anonymous functions. Go has support for first-class functions. In this post, we will see how to use anonymous functions in the Go programming language. What are Anonymous Functions? Anonymous functions are those which don’t need a name to be

Anonymous Functions in Golang Read More »

Recursion in Golang

Recursion is one of the important concepts in programming languages. In this post, we will learn how to use recursion in Go. What is Recursion? Recursion happens when a function calls itself, i.e it recurs. When a function inside a program calls itself recursion occurs. Criteria for Recursion To be a recursive function it has

Recursion in Golang Read More »