I'm working with a defined struct such as this one:
type MyList struct { Items []struct { ResourceLocation string `json:"resourceLocation"` Resource Tmp `json:"resource"` } `json:"items"` ListOptions } and I need to add a struct to Items slice.
I tried the following:
tmp2 := struct { ResourceLocation string Resource Tmp }{ Resource: myTempStruct, } tmpList.Items = append(MyList.Items, tmp) but I'm getting a:
Cannot use 'tmp' (type struct {...}) as type struct {...}
error.
By the way, I cannot modify
type MyList struct { Items []struct { ResourceLocation string `json:"resourceLocation"` Resource Tmp `json:"resource"` } `json:"items"` ListOptions } that's the reason why I cannot assign a name to Items and define it in a separate struct. Thanks.