I think the OPs question was specifically about the cost of returning from a function - it is the same.
> On Feb 3, 2022, at 8:03 PM, Connor Kuehl <cipku...@gmail.com> wrote: > > On Thu, Feb 3, 2022 at 7:07 PM Paulo Júnior <pauloafpjun...@gmail.com> wrote: >> >> Hi all. >> >> I hope you are well. >> >> Is there a big difference, in terms of performance or functionality, between >> declaring []*Person or []Person as a return type of a function? > > If you find yourself iterating over a group of structs like this a lot > (especially if there's a lot of them to iterate over), you might want > to consider measuring the performance differences between []*Person or > []Person. With pointers, the actual structs might be far away from > each other in memory, which may prevent you from taking full advantage > of your processor's cache since it won't be able to benefit from the > spatial locality that an array (or slice) offers. > > Connor > > -- > 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 on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAC_QXZS-QEKTgvsK3TKk-yUyc1jP81HngHz6dcDV8bZwqLBT6Q%40mail.gmail.com. -- 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 on the web visit https://groups.google.com/d/msgid/golang-nuts/EF34CFE5-9A6A-4CF7-80C4-83F730518260%40ix.netcom.com.