Overview In GO string are UTF-8 encoded. strings package of GO provides a Replace method that can be used to replace a character with another in a given string. It returns a…
Category: Tech
Replace some instances of a substring with another in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a Replace method that can be used to replace some non-overlapping instances of a given substring with a new substring….
Replace all instances of a substring with another in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a ReplaceAll method that can be used to replace all non-overlapping instances of a given substring with a new substring….
Find the index of the first instance of a substring in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides an Index method that can be used to get the index of the first occurrence of a substring in a…
Count instances of substring in a string in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a Count method that can be used to get the number of non-overlapping instances of a substring in a particular…
Trim leading and trailing whitespaces from a string in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a TrimSpace method that can be used to remove the leading and trailing whitespaces. Also, note that this function returns…
Trim suffix of a string in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a TrimSuffix method that can be used to remove a suffix string from the input string. If the input string…
Trim prefix of a string in Go (Golang)
Overview In GO string are UTF-8 encoded. strings package of GO provides a TrimPrefix method that can be used to remove a prefix string from the input string. If the input string…
Capitalize a string in Go (Golang)
Overview In Golang string are UTF-8 encoded. strings package of go provides a Title method that can be used to convert all first letters of all words in a sentence as capital….
Convert string to uppercase in Go (Golang)
Overview In Glang string are UTF-8 encoded. strings package of go language provides a ToUpper method that can be used to convert all Unicode letters to their upper case. This method will…