Guest User

Untitled

a guest
Dec 11th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "time"
  6. )
  7.  
  8. func change(c chan float64) float64 {
  9. time.Sleep(2 * time.Second)
  10. return 2.5
  11. }
  12.  
  13. func main() {
  14.  
  15. s := 1.1
  16.  
  17. c := make(chan float64)
  18. go change(c)
  19. s = <-c
  20.  
  21. for {
  22. fmt.Println(s)
  23. time.Sleep(100 * time.Millisecond)
  24. }
  25. }
  26.  
  27. fatal error: all goroutines are asleep - deadlock!
  28.  
  29. goroutine 1 [chan receive]:
  30. main.main()
  31. /home/kramer65/repos/go/src/messing_around/main.go:19 +0x7d
  32. exit status 2
Add Comment
Please, Sign In to add comment