I believe anonymous definitions of structs here is the cause. While equivalent, each anonymous definition is a distinct type.
Get Outlook for iOS<https://aka.ms/o0ukef> ________________________________ From: golang-nuts@googlegroups.com <golang-nuts@googlegroups.com> on behalf of Richard Whatever <c.richard.w...@gmail.com> Sent: Tuesday, August 30, 2022 7:46:47 AM To: golang-nuts <golang-nuts@googlegroups.com> Subject: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...} I'm developing a mvc Golang server. The model file is as follows: type Object struct { ... TargetSize struct{ width, height float64 } `json:"targetSize"` ... } The controller file is as follows: func (c *GetObject) Get() []models.Object { return []models.Object{ {... struct{ width, height float64 }{2.0, 3.0}, ... }, I keep on getting the error of "Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}" and I don't know how to resolve this. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com<mailto:golang-nuts+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a6b7d86c-8ed6-4be1-a265-3761f3b8be67n%40googlegroups.com<https://groups.google.com/d/msgid/golang-nuts/a6b7d86c-8ed6-4be1-a265-3761f3b8be67n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CO2PR07MB25839F3A272A2904D18033C7A0799%40CO2PR07MB2583.namprd07.prod.outlook.com.