title: Possible to add an append method to a slice
body: <p>I have something like the following type structure below:</p>
  
  <pre><code>type Set []*Element
  
  func (set *Set) AppendElements(elements []*Elements) {
      // ?
  }
  </code></pre>
  
  <p>Obviously simply appending elements to a slice is not very useful. However, the actual function takes some value, does some business logic, and then appends the elements. However, I am facing the difficulty that modifications to the slice inside of the method to not actually change the value of the slice to outside callers, because the append method allocates a new slice that is not seen by the callers.</p>
  
  <p>Is there a way to append to the slice in a method or should the slice be wrapped in a struct or something else?</p>
  
  <pre><code>package main
  
  import "fmt"
  
  type Element int
  type Set []*Element
  
  func (ptr *Set) AppendElements(elements []*Element) {
      set := *ptr
      set = append(set, elements...)
  }
  
  func main() {
      i := Element(1)
      var set Set
      set.AppendElements([]*Element{&amp;i})
  
      for _, el := range set {
          fmt.Println(el)
      }
  }
  </code></pre>
  
  <p>More specifically, the above prints nothing.</p>