title: Get length of a pointer array in Golang
body: <p>I am trying to append a vertex into the a slice of vertex by passing the pointer of that slice to the function <code>AppendVertex</code>, I know how to get the length of an array by using <code>len</code> function, but is there any way to get the the length of pointer array ?</p>
  
  <pre><code>type Vertex struct {
      X int
      Y int
  }
  
  func main() {
      var v []Vertex
      fmt.Println(len(v))
      appendVertex(&amp;v)
      fmt.Println(len(v))
  
  }
  
  func appendVertex(v *[]Vertex) {
  
      *v = append(*v, Vertex{1, 1})
  
      fmt.Println(len(v))
  }
  </code></pre>
  
  <p>Result for this one is </p>
  
  <pre><code>prog.go:22:16: invalid argument v (type *[]Vertex) for len
  </code></pre>
  
  <p>I also did another version by passing the pointer to the slice, however the size of slice did not changed, should't the slice is a reference type structure ? why  does the size did not changed here </p>
  
  <pre><code>type Vertex struct {
      X int
      Y int
  }
  
  func main() {
      var v []*Vertex
      fmt.Println(len(v))
      appendVertex(v)
      fmt.Println(len(v))
  
  }
  
  func appendVertex(v []*Vertex) {
  
      v = append(v, &amp;Vertex{1, 1})
  
      fmt.Println(len(v))
  }
  ​
  </code></pre>
  
  <p>Result for second one is </p>
  
  <pre><code>0
  1
  0
  </code></pre>