How to Check if a String Is Empty in Golang
This is the easiest thing I want to mention! Just use the equal (==) operator in golang: Code example:
This is the easiest thing I want to mention! Just use the equal (==) operator in golang: Code example:
Just call the HasPrefix function from the lovely strings package: Simple example code to check if a list of strings has a prefix:
Checking if a character or a substring exists in a string is so simple: And a simple example:
In Golang convert an object to JSON string (or a slice of bytes) is so simple by using the json package: In this example you… Read More »Golang: Simple Marshal Struct to JSON
If you came from the PHP or JS world then you want to know how you can write a foreach loop in the Golang 🙂… Read More »Is There a Foreach Loop in Go? [YES]
In Golang, you don’t have a special function that extracts the map keys for you. But it is as simple as this loop:
There are two ways to add an item to a map and one way to remove it from a map: Simple code example:
Do you want to check if a key exists in a map? Golang has a very simple syntax for it. You can check or even… Read More »Golang: Check if a Key Exists in a Map (If Contains)
If you want to work with a piece of string in Golang then your best friend is strings package! The split function can convert a… Read More »How to Split a String Into a Slice and Join Them Back [Golang]
Do you want to measure the execution time of a piece of code in Golang? Yes, there is a very simple solution using the Since… Read More »Golang: Easy Way to Measuring Execution Time (Elapsed Time)