github.com/yukk001/go1.10.8@v0.0.0-20190813125351-6df2d3982e20/doc/progs/timeout2.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package query 6 7 type Conn string 8 9 func (c Conn) DoQuery(query string) Result { 10 return Result("result") 11 } 12 13 type Result string 14 15 func Query(conns []Conn, query string) Result { 16 ch := make(chan Result, 1) 17 for _, conn := range conns { 18 go func(c Conn) { 19 select { 20 case ch <- c.DoQuery(query): 21 default: 22 } 23 }(conn) 24 } 25 return <-ch 26 } 27 28 // STOP OMIT