title: Is it possible for a function to change the size of a slice of string array declared elsewhere? golang
body: <p>I would like to remove an element from the slice in place. But when I do this I end up producing two empty elements in the underlying array.
  I already searched <a href="https://github.com/golang/go/wiki/SliceTricks" rel="nofollow noreferrer">here</a>, <a href="https://blog.golang.org/go-slices-usage-and-internals" rel="nofollow noreferrer">here</a> </p>
  
  <pre><code>package main
  
  import "fmt"
  
  //String remove adjacent duplicates from a string array
  func rmDup(str []string) []string {
      for i := 1; i &lt; len(str); i++ {
          if str[i] == str[i-1] {
              copy(str[i:], str[i+1:])
              str[len(str)-1] = ""
              str = str[:len(str)-1]
          }
      }
      return str
  }
  
  func main() {
  
      str := []string{"dog", "cat", "cat", "mouse", "mouse", "zebra", "zebra"}
  
      fmt.Println(str)
      newstr := rmDup(str)
      fmt.Println(str)
      fmt.Println(newstr)
      fmt.Println(len(str), cap(str), "final")
      fmt.Println(len(newstr), cap(newstr), "final")
  }
  </code></pre>
  
  <p>Is there any way that <strong>str</strong> in main can return the <strong>size</strong> and <strong>capacity</strong> defined in rmDup()</p>