title: Convert chan to non chan in golang
body: <p>Is it possible to let function <code>funcWithNonChanResult</code> have the following interface:</p>
  
  <pre><code>func funcWithNonChanResult() int {
  </code></pre>
  
  <p>And if I want it to use function <code>funcWithChanResult</code> with the interface:</p>
  
  <pre><code>func funcWithChanResult() chan int {
  </code></pre>
  
  <p>In other words, can I somehow convert <code>chan int</code> to <code>int</code>? Or I must have <code>chan int</code> result type in all the functions which use <code>funcWithChanResult</code>?</p>
  
  <p>Currently, I tried these methods:</p>
  
  <pre><code>result = funcWithChanResult() 
  //  cannot use funcWithChanResult() (type chan int) as type int in assignment
  
  
  result &lt;- funcWithChanResult() 
  // invalid operation: result &lt;- funcWithChanResult() (send to non-chan type int)
  </code></pre>
  
  <p>Full code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "time"
  )
  
  func getIntSlowly() int {
      time.Sleep(time.Millisecond * 500)
      return 123
  }
  
  func funcWithChanResult() chan int {
      chanint := make(chan int)
      go func() {
          chanint &lt;- getIntSlowly()
      }()
      return chanint
  }
  
  func funcWithNonChanResult() int {
      var result int
      result = funcWithChanResult() 
      // result &lt;- funcWithChanResult() 
      return result
  }
  
  func main() {
      fmt.Println("Received first int:", &lt;-funcWithChanResult())
      fmt.Println("Received second int:", funcWithNonChanResult())
  }
  </code></pre>
  
  <p><a href="http://play.golang.org/p/zFFZV0pR07" rel="noreferrer">Playground</a></p>