// NewCounterChannel() is required to initialize a Counter.
NewCounterChannel() is required to initialize a Counter.
// NewCounterChannel () is required to initialize a Counter .
func NewCounterChannel() *CounterChannel {
	c := &CounterChannel{
		readCh:  make(chan uint64),
		writeCh: make(chan int),
	}
	go func() {
		var count uint64 = 0
		for {
			select {
			case c.readCh <- count:
			case <-c.writeCh:
				count++
			}
		}
	}()
	return c
}
func NewCounterChannel ( ) * CounterChannel { c := & CounterChannel { readCh : make ( chan uint64 ) , writeCh : make ( chan int ) , } go func ( ) { var count uint64 = 0 for { select { case c . readCh <- count : case <- c . writeCh : count ++ } } } ( ) return c }
NewCounterChannel() is required to initialize a Counter.
NewCounterChannel () is required to initialize a Counter .
// The actual counter value lives inside this goroutine. // It can only be accessed for R/W via one of the channels. // Reading from readCh is equivalent to reading count. // Writing to the writeCh increments count.