The if-else expression in Golang

The if-statement is present in almost every programming language out there. It is one of the most important control-flow statements in programming. In this post, we will explore the different ways we can use the if statement to make our programs robust and concise. 1. The syntax of if-expression in GoLand The syntax of the

The if-else expression in Golang Read More »

Delete files in Golang

Deleting files is important when we want to do routine work with files. E.g. we save some log data and then after some time we may want to remove it automatically. This file deletion can be easily done in Go. In this post, we are going to discuss how to delete files in Go. Remove

Delete files in Golang Read More »

Write files in Golang

In this post, we are going to explore how to write into files in Golang. Go has the io, os, and ioutil (deprecated in Go1.16) package which makes writing a file a lot easier. So, let’s see what are the different ways we can do it. First step: Creating a File In order to write

Write files in Golang Read More »

Reading files in Golang

Reading files is one of the most essential tasks in programming. It allows us to see content, modify and write it using programming. In this post, we will see how to read file contents in Go. 1. Open a file for reading The first step is to open the file for reading. We can use

Reading files in Golang Read More »

String formatting in Golang

String formatting is essential when we need to create a string dynamically. String formatting makes our lives easier by allowing us to do things that can take much longer if done some other way. For example, we need to print a hex value of a number. Using string formatting it is a lot easier. In

String formatting in Golang Read More »

Comparing Strings in Golang

Comparing strings together is an important task that is almost unavoidable in large programs. In this post, we will see different ways of comparing strings in Golang. 1. Using the Golang Comparison Operators There is a multitude of comparison operators in Go. Each operator works in the way it looks. We will see what are

Comparing Strings in Golang Read More »