title: Is a struct actually copied between goroutines if sent over a Golang channel?
body: <p>If a large struct is sent over a channel in Go, is it actually copied between goroutines?</p>
  
  <p>For example, in the code below, will Go actually copy all largeStruct data between goroutines producer and consumer?</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "sync"
  )
  
  type largeStruct struct {
      buf [10000]int
  }
  
  func main() {
      ch := make(chan largeStruct)
      wg := &amp;sync.WaitGroup{}
      wg.Add(2)
      go consumer(wg, ch)
      go producer(wg, ch)
      wg.Wait()
  }
  
  func producer(wg *sync.WaitGroup, output chan&lt;- largeStruct) {
      defer wg.Done()
      for i := 0; i &lt; 5; i++ {
          fmt.Printf("producer: %d\n", i)
          output &lt;- largeStruct{}
      }
      close(output)
  }
  
  func consumer(wg *sync.WaitGroup, input &lt;-chan largeStruct) {
      defer wg.Done()
      i := 0
  LOOP:
      for {
          select {
          case _, ok := &lt;-input:
              if !ok {
                  break LOOP
              }
              fmt.Printf("consumer: %d\n", i)
              i++
          }
      }
  }
  </code></pre>
  
  <p>Playground: <a href="http://play.golang.org/p/fawEQnSDwB" rel="noreferrer">http://play.golang.org/p/fawEQnSDwB</a></p>