Created
October 15, 2022 15:31
-
-
Save by-sabbir/070fa9640e08c3ed7d6afb38c45c9fce to your computer and use it in GitHub Desktop.
concurrent write to the databse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ... | |
| 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