Skip to content

Instantly share code, notes, and snippets.

@just1689
Last active April 8, 2018 11:20
Show Gist options
  • Save just1689/76d24dc3801a2c47df1c6086b1c76a70 to your computer and use it in GitHub Desktop.
Save just1689/76d24dc3801a2c47df1c6086b1c76a70 to your computer and use it in GitHub Desktop.
Query multiple sources at once - return first
func Query(conns []Conn, query string) Result {
ch := make(chan Result)
for _, conn := range conns {
go func(c Conn) {
select {
case ch <- c.DoQuery(query):
default:
}
}(conn)
}
return <-ch
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment