How to Set Hour and Minute for a Golang Time
Yes, sometimes we are surprised by Golang standard library! There is no method on time package that helps you to set (update) the hour, minute,… Read More »How to Set Hour and Minute for a Golang Time
Yes, sometimes we are surprised by Golang standard library! There is no method on time package that helps you to set (update) the hour, minute,… Read More »How to Set Hour and Minute for a Golang Time
There is a super easy trick to format a number with thousand separator in any language.
fmt package is magic! I love it and you can use it to simplify many tasks especially the debugging process 🙂 Take a look at… Read More »Go: The Simplest Way to Dump complex Variables for Debugging
Technically what we’re making here is a slice with a defined length. It’s not possible to make an array in Go with a non constant… Read More »How to make a 2D or 3D array in Go
In Golang, there is no function to generate random numbers over a range! Writing a random generator function is easy and I wrote one for… Read More »How to Generate a Random Int Over a Range (func)
Oh we know the input format and we want to extract data from some exact position of that, Scanf from fmt package will help us:… Read More »Take a Formatted User Input in Golang (Extract Data)
You need to accept multiple inputs (with different types) from a user and all of them are in one line! Scanln from the fmt package… Read More »Go: How to Take Multiple User Inputs From One Line
Time package has a helper method to check a time.Time variable is zero value or not: Run this simple example to check how it works:
If your string contains some non-regular characters (like Chinese or Russian or currency signs) then you can calculate the length of your string using these… Read More »Go: How to Get the Length of a String With Non-regular Characters
On the response writer variable call the Header() method and then Set() to set the header you want to add: This snippet is complete and… Read More »Set Header to Response in Golang (HTTP Handler)