title: Using a pointer to array
body: <p>I'm having a little play with google's Go language, and I've run into something which is fairly basic in C but doesn't seem to be covered in the documentation I've seen so far</p>
  
  <p>When I pass a pointer to a slice to a function, I presumed we'd have some way to access it as follows:</p>
  
  <pre><code>func conv(x []int, xlen int, h []int, hlen int, y *[]int)
  
      for i := 0; i&lt;xlen; i++ {
          for j := 0; j&lt;hlen; j++ {
              *y[i+j] += x[i]*h[j]
          }
      }
   }
  </code></pre>
  
  <p>But the Go compiler doesn't like this:</p>
  
  <pre><code>sean@spray:~/dev$ 8g broke.go
  broke.go:8: invalid operation: y[i + j] (index of type *[]int)
  </code></pre>
  
  <p>Fair enough - it was just a guess. I have got a fairly straightforward workaround:</p>
  
  <pre><code>func conv(x []int, xlen int, h []int, hlen int, y_ *[]int) {
      y := *y_
  
      for i := 0; i&lt;xlen; i++ {
          for j := 0; j&lt;hlen; j++ {
              y[i+j] += x[i]*h[j]
          }
      }
  }
  </code></pre>
  
  <p>But surely there's a better way. The annoying thing is that googling for info on Go isn't very useful as all sorts of C/C++/unrelated results appear for most search terms.</p>