title: Problems about `slice` and `append` in Go
body: <p>I have written the following code. But I can't have it compiled. Here is my code:</p>
  
  <pre class="lang-go prettyprint-override"><code>package main
  
  import "fmt"
  
  func main() {
      tmp := make([]int, 10)
      for i := 0; i &lt; 10; i++ {
          tmp[i] = i
      }
      res := mapx(foo, tmp)
      fmt.Printf("%v\n", res)
  }
  
  func foo(a int) int {
      return a + 10
  }
  
  func mapx(functionx func(int) int, list []int) (res []int) {
      res = make([]int, 10)
      for _, i := range(list) {
          append(res, functionx(i))
      }
      return
  }
  </code></pre>
  
  <p>Meanwhile the error message is also very confusing:
  <code>prog.go:21: append(res, functionx(i)) not used</code></p>
  
  <p>But if I replace <code>append(res, functionx(i))</code>(line 21) with <code>res = append(res, functionx(i))</code>, it works quite well. Can anybody help me?</p>
  
  <p>Thank you!</p>