Overview The regexp.MustCompile function is used to compile the given regex string. So the input to the MustCompile function is a string only. And since it is a string we can concatenate any…
Tag: golang
Golang regex match any character
Overview Dot ‘.’ character is one of the most commonly used metacharacters in the regular expression. It is used to match any character. By default, it doesn’t match a new line. Program…
JSON parse a file in Go (Golang)
Overview encoding/json package provides an Unmarshal method that can be used to convert the file bytes into struct or map in golang. json.Unmarshal function can be used to convert from JSON to a struct…
All Data Structures in Go (Golang)
Data Structures in Golang Queue Stack Set Linked List Doubly Linked List Binary Search Tree Recursive Iterative Heap Minheap Maxheap Trie Sorting Algorithms Heap Sort Insertion Sort Selection Sort Bubble Sort Integers…
Get or Extract Query Params from a URL in Go (Golang)
Overview Query function of the URL instance can be used to get the query params present in a URL https://pkg.go.dev/net/url#URL.Query Note that query param is represented as below in Golang https://pkg.go.dev/net/url#Values which…
Get full hostname along with port from a URL in Go (Golang)
Overview net/url package of golang contains a Parse function that can be used to parse a given and return the URL instance of the URL structhttps://golang.org/pkg/net/url/#URL Once the given URL is parsed…
Convert Query Param String to Query Param Hash in Go (Golang)
Overview Assume we have below query param string We want the output as a map as below Program Below is the program for the same Output
Extract a URL from a string in Go (Golang)
Overview Below go package can be used to extract URL from a given string https://github.com/mvdan/xurls There are two ways of using this package Strict – In strict mode, it matches only URLs…
Parse a URL and extract all the parts in Go (Golang)
Overview net/url package of golang contains a Parse function that can be used to parse a given and return the url instance of the URL struct https://golang.org/pkg/net/url/#URL Once the given URL is…
Create Slice or Array of Strings in Go (Golang)
Overview It is possible to create a slice or array of string data type in Golang as well. In fact, a slice or array can be created of any data type in…