title: Deadlock in goroutine with GopherJS
body: <p>Why is there a deadlock in the following code? I am trying to return something from the goroutine to outside</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "syscall/js"
      "time"
  )
  
  func test(this js.Value, i []js.Value) interface{} {
      done := make(chan string, 1)
  
      go func() {
          doRequest := func(this js.Value, i []js.Value) interface{} {
              time.Sleep(time.Second)
  
              return 0
          }
  
          js.Global().Set("doRequest", js.FuncOf(doRequest))
          args := []js.Value{js.ValueOf("url")}
          var x js.Value
          doRequest(x, args)
          done &lt;- "true"
      }()
  
      aa := &lt;-done
      fmt.Println(aa)
  
      return 0
  }
  
  func main() {
      c := make(chan bool)
      js.Global().Set("test", js.FuncOf(test))
      &lt;-c
  }
  </code></pre>
  
  <p>When I run this on a browser and call test(),  the following error will be shown</p>
  
  <pre><code>fatal error: all goroutines are asleep - deadlock!
  goroutine 1 [chan receive]:
  .....
  </code></pre>