Being new to a Go, I am bit unsure how to perform a object creation in Go for Json Marshalling. I have a structure that I want to create var object out of it.
type myStruct struct {
A struct {
B struct {
C bool `json: "c", omitempty`
}
}
}
type a struct {
B b `json:"b"`
}
type b struct {
C bool `json:"c",omitempty`
}
and the corresponding instant I wanted to create is this
var myStructVar = myStruct {
a{
b{
C: valC, // valC is a constant in my case
},
},
}
But when I execute this it gives me error
cannot use a{…} (value of type a) as type struct ..... in struct literal