title: Golang, Go : why pointer use star operator instead of &
body: <p>The <a href="http://play.golang.org/p/-a6zv4Q3Xl" rel="noreferrer">code</a>:</p>
  
  <pre><code>type ByteSlice []byte
  
  func (p *ByteSlice) Append(data []byte) {
    slice := *p
    slice = append(slice, data...)
    *p = slice
  }
  
  func main() {
    x := ByteSlice{1, 2, 3}
    y := []byte{4, 5}
    x.Append(y)
    fmt.Println(x)
  }
  </code></pre>
  
  <p>Ok, I understand why and how pointer works, but I've always wondered why we use <code>*</code> operator to pass pointer to function.</p>
  
  <ul>
  <li><code>*ptr</code> is to deference the ptr and return the value saved in the pointer ptr.</li>
  <li><code>&amp;var</code> returns the address of the variable var.</li>
  </ul>
  
  <p>Why we do not use <code>&amp;ByteSlice</code> to pass pointer to function? </p>
  
  <p>I am confused. Isn't this function passing pointer? </p>
  
  <p>According to Go spec (<a href="http://golang.org/ref/spec#Pointer_types" rel="noreferrer">http://golang.org/ref/spec#Pointer_types</a>)</p>
  
  <blockquote>
    <p>PointerType = "*" BaseType .</p>
    
    <p>BaseType = Type .</p>
  </blockquote>
  
  <p>This also confuses me. Why we use star(<code>*</code>) operator both to get the pointer of variable and dereference pointer? Looks like we don't use <code>&amp;</code> for this case both in C and Go...</p>