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