I am marshaling values into a struct from JSON. This is my struct:
type AutoGenerated struct {
ID int64 `json:"id"`
SuccessHTTPResponseCode int `json:"success_http_response_code"`
MaxRetries int `json:"max_retries"`
CallbackWebhookURL string `json:"callback_webhook_url"`
Request struct {
URL string `json:"url"` (error occurs here)
Method string `json:"method"`
HTTPHeaders struct {
ContentType string `json:"content-Type"`
Accept string `json:"accept"`
} `json:"http_headers"`
Body struct {
Foo string `json:"foo"`
} `json:"body"`
} `json:"request"`
}
Below is the function where I marshal it:
func createBSON() []byte {
data1:= AutoGenerated{
ID: 1462406556741,
SuccessHTTPResponseCode: 200,
MaxRetries: 3,
CallbackWebhookURL: "http://requestb.in/vh61ztvh",
Request: {
URL: "http://requestb.in/vh61ztvh",
Method: "POST",
HTTPHeaders: {
ContentType: "Application/json",
Accept: "Application/json",
},
Body : {
Foo: "bar",
},
},
}
sample,err:=json.Marshal(data1)
check(err)
fmt.Print(sample)
return sample
}
I made a couple of changes and the above is my updated function. I am getting the following error:
missing type in composite literal
I am kind of new to Golang. I can't figure out what this error is. Any help would be appreciated.