title: why go channel is not garbage collected and closed even after completion of function
body: <pre><code>    package main
  
  import (
          &quot;fmt&quot;
  
      )
  
      func main(){
          leak()
          for{}
        }
  
  func leak() {
      ch := make(chan int)
  
      go func() {
          fmt.Println(&quot;i am stuck here&quot;)
          val := &lt;-ch
          fmt.Println(&quot;We received a value:&quot;, val)
          
      }()
      fmt.Println(&quot;i have finished my fuction&quot;)
  }
  </code></pre>
  <p>here since my channel &quot;ch&quot; is defined inside leak() function, so my understanding is after leak function is finished and returned, &quot;ch&quot; will be out of scope and should be garbage collected, but its open and go-routine waits indefinitely for value to receive from it,
  what is actually ahappening??</p>