It depends on what you do with it, and how you use it.

[]*Person is a slice of pointers, they're small.
[]Person is a slice of structs, they're bigger than pointers.

The first requires a level of indirection to access, the second doesn't.
The first requires no copying of structs when you're iterating or resizing,
while the second requires copying entire structs.

So, either could be faster based on what you do with it.

On Thu, Feb 3, 2022 at 5:10 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?
>
> Code sample https://go.dev/play/p/tBAod1hZvYu
>
> Thank you and best regards.
> Paulo.
>
> --
> 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/964eb09d-cd5f-4da1-b1ca-cac3e9b5bb69n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/964eb09d-cd5f-4da1-b1ca-cac3e9b5bb69n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CA%2Bv29LtxpB6cdryT0sfh1AXmf1X%2BJS0di40y0%2BYpmxz94Z1CeQ%40mail.gmail.com.

Reply via email to