Got it. I've read both the *references* shared, it seems these rules can be 
used to understand if we should pass the value or pointer to a *function 
argument*. 
But, Can we really say that, the same rules apply for the return types as 
well ? 
I want to make idiomatic decision when to return 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 <tusharr...@gmail.com> wrote:
> >
> > 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 other 
> once ?
>
> There are no hard and fast rules. There are some guidelines at
> https://go.dev/wiki/CodeReviewComments#pass-values and
> https://go.dev/wiki/CodeReviewComments#receiver-type.
>
> Ian
>

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/ed41d429-748d-46f8-9a5c-16a71a2a6049n%40googlegroups.com.

Reply via email to