Is this syntax a pointer to slice or slice of pointers?
After looking at this blog post , I'm still unclear if the following syntax means fragment pointers or pointer to fragment.
foo []*int
Which one and what is the general rule for this case?
source to share
This is a snippet of int pointers. []
the parentheses appear before the type, so *int
is the type in your example, but *[]int
is a pointer to an int array, or * [] * int for a pointer to an array of int pointers.
Whatever the style, I wouldn't use the syntax *[]int
in favor at all or something like foo := &[]int{}
that, which results in being foo
a pointer to the start of a new int array.
source to share