I just started practicing with channels, after writing to the channel, 
nothing is output from there
func main() {
    d := make(chan int)
    go factorial(5, d)
     time.Sleep(3 * time.Second)
}

func factorial(n int, d chan int) {
    fmt.Println("function starting...")
    time.Sleep(3 * time.Second)
    var a int = 1
    for ; n > 0; n-- {
        a *= n
    }
    d <- a // //nothing works after that
    fmt.Println(<-d)
    fmt.Println(a)
}
--------------------------------------------------------------------------------------------------------------------------------------------
Another question I want to make a recursive function with a factorial, pass 
it to goroutine in main. But I do not know if it is possible to somehow 
combine *return* and a channel in the declaration of arguments.
---------------------------------------------------------------------------------------------------------------------------------------------
if I first pass in something to the channel from main,
a lock occurs.Why? So it's not possible at all?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f7527636-00e0-42d1-84f4-7aebcf12c984n%40googlegroups.com.

Reply via email to