github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/backup/select12.gno (about)

     1  package main
     2  
     3  type S struct {
     4  	q chan struct{}
     5  }
     6  
     7  func (s *S) Send() {
     8  	select {
     9  	case s.q <- struct{}{}:
    10  		println("sent")
    11  	default:
    12  		println("unexpected")
    13  	}
    14  }
    15  func main() {
    16  	s := &S{q: make(chan struct{}, 1)}
    17  	s.Send()
    18  	println("bye")
    19  }
    20  
    21  // Output:
    22  // sent
    23  // bye