timeout2.go 515 B

12345678910111213141516171819202122232425262728
  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. package query
  5. type Conn string
  6. func (c Conn) DoQuery(query string) Result {
  7. return Result("result")
  8. }
  9. type Result string
  10. func Query(conns []Conn, query string) Result {
  11. ch := make(chan Result, 1)
  12. for _, conn := range conns {
  13. go func(c Conn) {
  14. select {
  15. case ch <- c.DoQuery(query):
  16. default:
  17. }
  18. }(conn)
  19. }
  20. return <-ch
  21. }
  22. // STOP OMIT