On Tue, 2022-08-30 at 07:46 -0700, Richard Whatever wrote:
> 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'll benefit from defining the type struct{ width, height float64 }
if you need to use it elsewhere. Also, for JSON de/serialisation, the
fields will need to be exported. This will also fix you compile.

-- 
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/1caf865a134ec3d0173fdf946b484db2cd500e3a.camel%40kortschak.io.

Reply via email to