Pointers to arrays in golang

1. How to represent the pointer to the array in golang?
2. How to pass a pointer to an array in a function?

I don"t quite understand the pointers to arrays in golang. Any great god will use a case to analyze the above two problems.
No good answers have been found on the Internet (are there fewer pointers to arrays)?

Mar.09,2021

is right. In general, you don't have to pass pointers to map and slice to save memory overhead, but in some unmarshal scenarios you will use their pointers


map and slice are "pointers" (or "references").


  1. Array pointer indicates
 

array is a value type in go, but is simply a collection of elements of a single type of the underlying type int, float, bool, or string. There are two ways to use array pointers:
1. Use slice
2. As a normal value type, use & to get the address

pointer array passes parameters in the same way.

Menu