Unit testing in Golang

Unit testing is essential when creating software. It tests each component one after another but does not test it entirely. In this post, we will use the testing package to do some unit testing in Go. What is testing? Testing is when we want to check the correctness of our code. It’s a really important […]

Unit testing in Golang Read More »

Closures in Golang

Go has support for first-class functions, which means the functions can be used pretty much everywhere. This creates a new property for the function to become aware of its surroundings. This property is called the closure property. What is Closure in Golang? Closure occurs when an anonymous function in Go has access to its surroundings.

Closures in Golang Read More »

Reflection in Golang

Reflection is an advanced programming concept, which in some programming languages allows the program to check types and values at runtime. Go has a package for reflection – the reflect package. In this post, we are going to discuss how to do reflection in Go. What is Reflection in Programming? Reflection is the way a

Reflection in Golang Read More »

The “time” package in Go

The time package contains everything useful about time. In this post, we are going to explore the time package in Go. The Sleep() function in time package First, we need to import the time package to do something with it. The time package has a sleep function that can pause the main Go thread. The

The “time” package in Go Read More »

Packages in Golang

Packages allow us to focus on the code reuse principle aka the DRY (Don’t Repeat Yourself) principle. It enables us to write concise code in a structured manner. In this post, we are going to take a look at the package system in Go. What is a package in Go? A package is essentially a

Packages in Golang Read More »

Pointer to a function in Golang

Go has no apparent “pointer to a function” but it can store the functions and call it later making the function pointers implicitly defined. What is a function pointer? In some programming languages like C/C++, there can be a pointer that can store the address of a function and later call it using itself. This

Pointer to a function in Golang Read More »

Pointer to a struct in Golang

Pointers are a useful entity that stores a memory address in it. Structs are the building blocks of data structures in Go. In this post, we are going to explore pointers to a struct in Golang. Pointer to a Struct Syntax The syntax of a pointer to a struct is just like any other pointer.

Pointer to a struct in Golang Read More »

The list container in Go

Lists are an important aspect of programming. It is one of the most important data structures used today. In this post, we are going to explore about lists in Go. The “container/list” package To use lists in Go, we import the list package inside the container package. Then we can use the lists in Go

The list container in Go Read More »