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…
Category: Tech
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…
HTTP Client to not follow redirect in Go (Golang)
Overview http.Client struct is used to make HTTP requests in golang. https://golang.org/src/net/http/client.go http.Client lets you specify a policy of how redirects can be handled. Below is the structure of http.Client struct The…
Validate the range of the integer in an HTTP request body in Go (Golang)
Overview The below library can be used to validate the range of an integer in an incoming JSON HTTP request body gopkg.in/go-playground/validator.v9 – https://pkg.go.dev/github.com/go-playground/validator For this tutorial, we will try to parse…
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…
HTTP- Understanding multipart/form-data content-type
In HTTP context, the multipart/form-data content-type is used for submitting HTML form. In the case of multipart/form-data, as the name suggests the body consists of different parts separated by a delimiter or…