m: Robert Engels
> >Sent: Nov 20, 2019 2:25 PM
> >To: Ian Lance Taylor , Orson Cart <
> objectivedynam...@gmail.com>
> >Cc: golang-nuts
> >Subject: Re: [go-nuts] Difference with function returning struct and
> function returning pointer to struct
> >
> >
ng, especially the statement "Changing
>>a field in that copy won't change anything." because even if I have a copy, I
>>should be able to change the fields, and the changes would be there for the
>>scope, and if I returned the copy, whether by address or copy, the changes
>>
the
other code?
-Original Message-
>From: Robert Engels
>Sent: Nov 20, 2019 2:25 PM
>To: Ian Lance Taylor , Orson Cart
>
>Cc: golang-nuts
>Subject: Re: [go-nuts] Difference with function returning struct and function
>returning pointer to struct
>
>
>
ss or copy, the changes
would be retained.
-Original Message-
>From: Ian Lance Taylor
>Sent: Nov 20, 2019 11:55 AM
>To: Orson Cart
>Cc: golang-nuts
>Subject: Re: [go-nuts] Difference with function returning struct and function
>returning pointer to struct
>
>On
On Wednesday, 20 November 2019 17:55:59 UTC, Ian Lance Taylor wrote:
>
> The other kind of answer is that if a function returns a pointer to a
> struct, a value of type *employee, then it's normal for that something
> else to have a copy of that pointer, perhaps some data structure or
> global
On Wednesday, 20 November 2019 17:55:00 UTC, Thomas Bushnell, BSG wrote:
but the return value of a function is not addressable (it's not a variable,
pointer, etc etc).
Hi Thomas. Apologies, I said "assignable" when I meant "addressable". I was
curious as to why a struct returned from a
On Wed, Nov 20, 2019 at 9:41 AM Orson Cart wrote:
>
> I'm a newbie to Go having used C and C++ in the past and I'm puzzled about
> something I've just seen.
>
> In the following code getEmployee returns a pointer to a struct. The return
> value is then dereferenced. This code compiles and runs
You can only assign to something which is addressable in the sense of
https://golang.org/ref/spec#Address_operators.
That is: "either a variable, pointer indirection, or slice indexing
operation; or a field selector of an addressable struct operand; or an
array indexing operation of an
I'm a newbie to Go having used C and C++ in the past and I'm puzzled about
something I've just seen.
In the following code getEmployee returns a pointer to a struct. The return
value is then dereferenced. This code compiles and runs fine:
package main
type employee struct {
ID int
name