Re: [go-nuts] Returning a pointer or value struct.

2024-11-01 Thread Tushar Rawat
pies of Ints are not > > supported and may lead to errors. > > > > func (z *Int <https://pkg.go.dev/math/big#Int>) Set(x *Int > <https://pkg.go.dev/math/big#Int>) *Int <https://pkg.go.dev/math/big#Int> // > signature of math/big.Int.Set() > > Hope th

Re: [go-nuts] Returning a pointer or value struct.

2024-10-31 Thread Tushar Rawat
urn a struct as value and when as pointer. Regards, Tushar On Thursday, October 31, 2024 at 11:03:13 PM UTC+5:30 Ian Lance Taylor wrote: > On Thu, Oct 31, 2024 at 6:24 AM Tushar Rawat wrote: > > > > I have seen few places where functions are returning struct as a value > (fo

[go-nuts] Returning a pointer or value struct.

2024-10-31 Thread Tushar Rawat
I have seen few places where functions are returning struct as a value (for instance time package, time is always returned as a value) and however at some places folks prefer to return the pointers to struct instead of the copy. Which one should be idiomatic approach, and when should we prefer