File: changoroutines.go

package info (click to toggle)
delve 1.24.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,092 kB
  • sloc: ansic: 111,943; sh: 169; asm: 141; makefile: 43; python: 23
file content (26 lines) | stat: -rw-r--r-- 384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main

import (
	"runtime"
	"time"
)

func main() {
	blockingchan1 := make(chan int)
	blockingchan2 := make(chan int)

	go sendToChan("one", blockingchan1)
	go sendToChan("two", blockingchan1)
	go recvFromChan(blockingchan2)
	time.Sleep(time.Second)

	runtime.Breakpoint()
}

func sendToChan(name string, ch chan<- int) {
	ch <- 1
}

func recvFromChan(ch <-chan int) {
	<-ch
}