In this article, we will see how to change the DateTime format in Golang using the time package. We also see how to parse and format the DateTime values. Parsing: You must first parse the date string into a time.Time…
In this article, we will see how to validate a date string format in Golang. To achieve this we use the time package. To validate a date string format, you can use the time.Parse function. The time.Parse function takes two…
In this article, we will see how to list the directories, subdirectories and files recursively. Here, we use thefilepath.Walk function to recursively traverse a directory and its subdirectories to list all the directories, subdirectories, and files efficiently. Following is the…
In this article, we will see how to unmarshal nested json data as a string/raw json data using Json.RawMessage. There are several use cases of delaying the json decoding using the RawMessage. json.RawMessage is mostly used for handling JSON data…
In this article, we will see how to generate a random date between two dates in golang. In golang, we can use Date function in the time package to generate a random date between two dates. Following is the example…
In this article, we will see how to split a string by its length in golang. We can easily do this by using the slice expression. It represents a portion of the string s that starts at index i and…
In this article, we will see how to use the Context package to set a timeout, and how this can be used to manage concurrent processes in Golang. Context is a powerful package & the ability to establish a timeout…
In this article, we will see how to create an alias for a type in Golang and the benefits it provides. In Golang, it is possible to create an alias for a type. This is useful when you want to…
In this article, we will see how to implement a function that will generate a random hash of the specified format with the given length. The below function generates the random hash of the following formats. Explanation:
There are some specifications that mandate the clients send requests in random intervals to the server, particularly during the error scenarios. In such a scenario, a random sleep is necessary to wait before sending the request again to the server….