Mukul Latiyan has Published 474 Articles

Array shift function in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:12:40

500 Views

Sometimes we need to extract a portion of an array data and perform some operation on the extracted data. In Ruby, we can perform such operations with the help of the shift() function.The shift() function takes one argument, which is an index that is used to remove the first element ... Read More

How to handle errors within WaitGroups in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 06:58:49

3K+ Views

There are chances that we might get some panic while running multiple goroutines. To deal with such a scenario, we can use a combination of channel and waitgroups to handle the error successfully and not to exit the process.Let's suppose there's a function that when invoked returns a panic, which ... Read More

How to wait for a goroutine to finish in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:46:39

7K+ Views

We know that goroutines can be a bit tricky at first, and often we find cases where the main goroutines will exit without giving a chance to the inside goroutines to execute.In order to be able to run the goroutines until the finish, we can either make use of a ... Read More

How to concatenate two slices in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:43:33

3K+ Views

Whenever we talk about appending elements to a slice, we know that we need to use the append() function that takes a slice as the first argument and the values that we want to append as the next argument.The syntax looks something like this.sl = append(sl, 1)Instead of appending a ... Read More

Sorting in Golang with sort Package

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:40:50

486 Views

The standard library of Golang provides a package that we can use if we want to sort arrays, slices, or even custom types. In this article, we will discover three main functions that we can use if we want to sort a slice in Golang. We will also see how ... Read More

How to use iota in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:32:09

5K+ Views

Iota in Go is used to represent constant increasing sequences. When repeated in a constant, its value gets incremented after each specification. In this article, we will explore the different ways in which we can use iota in Go.Let's first consider a very basic example, where we will declare multiple ... Read More

How to parse Date strings in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:28:17

12K+ Views

When it comes to parsing Date strings in Go, we can use the Parse function that is provided by the time package. In Go, we don't use codes like most other languages to represent the component parts of a date/time string. Instead, Go uses the mnemonic device - standard time ... Read More

Anonymous goroutines in Golang

Mukul Latiyan

Mukul Latiyan

Updated on 22-Feb-2022 05:22:37

3K+ Views

In order to be able to understand the anonymous goroutines, we must be aware of the existence of anonymous functions and goroutines. We will first explore the anonymous functions that are the real reason behind the motivation of anonymous goroutines and then we will learn a little about what goroutines ... Read More

How to check if a string contains a substring in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 21-Feb-2022 08:16:10

712 Views

We know that substrings are a contiguous sequence of characters in a string, and in order to check whether a string contains a substring, we have two options available.The first approach is to use a built-in function called Contains() and the second approach is to make use a self-written logic ... Read More

How to compare slices, structs and maps in Golang?

Mukul Latiyan

Mukul Latiyan

Updated on 21-Feb-2022 08:09:20

1K+ Views

The reflect package in Go provides a very important function called DeepEqual() which can be used to compare composite types. The DeepEqual() function is used when we want to check if two data types are "deeply equal".Comparing slicesExample 1Consider the code shown belowpackage main import (    "fmt"    "reflect" ... Read More

Advertisements