On Thu, Oct 31, 2024 at 6:24 AM Tushar Rawat <tusharrawat...@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/CAOyqgcXrxRK1FtbHtc5TaS9SK%3DyW8EqezXQ4B1pqY-PLeqCUcg%40mail.gmail.com.

Reply via email to