Skip to content

Instantly share code, notes, and snippets.

@by-sabbir
Created October 15, 2022 15:31
Show Gist options
  • Save by-sabbir/070fa9640e08c3ed7d6afb38c45c9fce to your computer and use it in GitHub Desktop.
Save by-sabbir/070fa9640e08c3ed7d6afb38c45c9fce to your computer and use it in GitHub Desktop.
concurrent write to the databse
...
rowCh := make(chan *sql.Rows, 1)
errCh := make(chan error, 1)
go func() {
row, err := db.Client.QueryContext(
ctx,
qs,
...
)
rowCh <- row
errCh <- err
}()
... // check for error and close the row (<-rowCh)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment