Creating a balancing device with a container / ring of channels in the golang

I am trying to do load balancing with a container / ring of channels, and I am having trouble recording them. The ring seems to take the {} interface as the type that causes the problem when I try to write the assigned channel to it.

The error that appears is

prog.go:11: invalid operation: chring.Value <- true (send to non-chan type interface {}) 

simplified code: http://play.golang.org/p/AJs2MV_UUC

 package main //import "fmt" import "container/ring" func main() { chring := ring.New(10) for i:=0;i<10;i++ { ch:=make(chan bool) chring.Value=ch chring.Value <- true //dies here chring = chring.Next() } } 
+4
source share
1 answer

Use a statement like :

 chring.Value.(chan bool) <- true 
+3
source

Source: https://habr.com/ru/post/1480985/


All Articles