Re: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread Richard Whatever
Thanks for the assistance. Issue resolved by naming "width" and "height"
with the capital starting letter, "Width" and "Height". Looks like I'm
still not familiar with the Go export syntax yet.

Harris, Andrew  于2022年8月31日周三 06:07写道:

> 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  on
> behalf of Richard Whatever 
> *Sent:* Tuesday, August 30, 2022 7:46:47 AM
> *To:* golang-nuts 
> *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.
> 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_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/CAKS_JOh5FWwmnV8q-ECsn%3DyL7BV5fO78ZwVkPMBoSCi8itr%2B7w%40mail.gmail.com.


Re: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread Harris, Andrew
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  on behalf of 
Richard Whatever 
Sent: Tuesday, August 30, 2022 7:46:47 AM
To: golang-nuts 
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_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.


Re: [go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread 'Dan Kortschak' via golang-nuts
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.


[go-nuts] How to resolve error Cannot use 'struct{ width, height float64 }{2.0, 3.0}' (type struct {...}) as the type struct {...}

2022-08-30 Thread Richard Whatever


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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a6b7d86c-8ed6-4be1-a265-3761f3b8be67n%40googlegroups.com.