Golang HTTP Request With JSON Body
Just use this snippet which sends a post request with a JSON body. It saves your time :). I know you are not comfortable with… Read More »Golang HTTP Request With JSON Body
Just use this snippet which sends a post request with a JSON body. It saves your time :). I know you are not comfortable with… Read More »Golang HTTP Request With JSON Body
The simplest way to check if two structs are equal is using the DeepEqual method from the reflect package: See this example which shows the… Read More »Compare if Slices Are Equal in Golang (Struct, Map, Interface, …)
If you are interested in the order of your slice and want to remove some of them in an efficient way this snippet is for… Read More »Efficiently Keep Order When Removing Elements From a Slice in Golang
If you want to remove a field from a struct just put `json:”-“` in front of the fields you want to hide: Take a look… Read More »Golang: Removing or Hiding Fields in JSON Marshal
Ok, we want to accept input from the user for example from the command line (terminal). Our friend, the fmt package is with us! Scanln… Read More »Read User Input From Terminal (Stdin) In Golang
Golang is very good at making and responding to requests 🙂 Request struct has a Header type that implements this Set method: A working example… Read More »Golang HTTP Request Header Example
Get the index of the last item in Golang by using len() method: The slice index starts from 0 and you can access the last… Read More »Go: Remove the Last Element From a Slice
Tags in struct definition are useful when you want to convert structs to other types, especially JSON. Just use the omitempty in front of the… Read More »Golang JSON: How to Make a Field Optional (omitempty)
The simplest way to range between two numbers in golang is a for loop, in this example, we iterate 5 to 10: There is a… Read More »Range Between Two Numbers in Golang
Creating a queue in the Golang is easy and it can be written in some line of code. Pop from a slice can be done… Read More »Golang: Remove (Pop) First Element From Slice