Being new to Go, I decided to try writing a very simple REST API. I'm writing here about the bizarre problem I encountered writing it and how it took me a very long time to find the solution. To professional Go programmers this might sound very trivial. But coming from a background of mainstream OO langages, I found this pretty unconventional.
So lets look at a simple program that handles a http POST request. The request sends along some JSON data. Usually to store and parse JSON data you create a struct similar to the structure of the incoming JSON and decode the JSON and store it in an object of the struct. Lets have a look at a sample code:
type test_struct struct {
Test string `json:"test"`
}