Overview REST is an architectural style built on top of HTTP/1. GRPC is not a style instead it is an RPC framework built on top of HTTP/2 and it uses protocol buffers…
Tag: golang
How to initialize a struct having an array or slice field in Go (Golang)
Overview A struct can have a field which is a slice or array of another type. To initialize such a struct we can initialize the slice/array of another type first. After that, we…
How to intialize a struct that has another nested struct in Go (Golang)
Overview A struct can have another struct nested in it. Let’s see an example of a nested struct. In below example employee struct has the address struct nested it in. To initialize such kind of struct…
Validate the range of the integer in a struct in Go (Golang)
Overview The below library can be used to validate the range of an integer in a struct in Golang gopkg.in/go-playground/validator.v9 – https://pkg.go.dev/github.com/go-playground/validator For this tutorial, we will use the below employee struct…
Validate the presence of the field in a struct in Go (Golang)
Overview In this tutorial, we will explore two libraries that can be used to validate the field of a struct in Golang. The two libraries are gopkg.in/go-playground/validator.v9 – https://pkg.go.dev/github.com/go-playground/validator github.com/asaskevich/govalidator – https://github.com/asaskevich/govalidator…
Set a timeout while making an HTTP request in Go (Golang)
Overview client struct of HTTP package can be used to specify the timeout. While creating the HTTP client we can specify the value of the Timeout. An important thing to note about…
ASCII digit to the character in Go (Golang)
Overview Below is the simple program to convert an ASCII digit to its corresponding character in go. We can simply typecast the number to the string. That will convert it into its…
Convert a JSON to map in Go (Golang)
Overview encoding/json package provides utilities that can be used to convert to and from JSON. The same utility can be used to convert a golang map to JSON string and vice versa….
Convert a map to JSON in Go (Golang)
Overview encoding/json package provides utilities that can be used to convert to and from JSON. The same utility can be used to convert a golang map to JSON string and vice versa….
Conversion between map and JSON in Go (Golang)
Overview encoding/json package provides utilities that can be used to convert to and from JSON. The same utility can be used to convert a golang map to JSON string and vice versa….