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.

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 From: golang-nuts@googlegroups.com on behalf of Richard Whatever Sent: Tuesday, August 30, 2

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() []mode

[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 fl

[go-nuts] Re: How to get name of variable name from pointer name?

2022-08-30 Thread Howard C. Shaw III
In the instant example where you have the name in the code, just include the name as a string: fmt.Printf("Type: %T, Name:%#+v\n", myVariable, "myVariable") But in the general case where that pointer value has been passed to a function or stored in a map or slice and you are referencing

[go-nuts] How to get name of variable name from pointer name?

2022-08-30 Thread Furkan Türkal
Is there any way to get the variable name from the underlying pointer type? I couldn't figure it out how to get the name of the variable from the pointer type, since that name doesn't exist anymore at runtime. - https://go.dev/play/p/ulaiQ1F4hbQ My use-case: Image I have a large list of `*bar`