Use context.Context in module.Table

Closes #366.
This commit is contained in:
fox.cpp 2021-07-10 13:27:37 +03:00
parent 5c143530ff
commit 6d44617840
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0
19 changed files with 61 additions and 42 deletions

View file

@ -19,6 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package table
import (
"context"
"database/sql"
"fmt"
"strings"
@ -130,9 +131,9 @@ func (s *SQL) Close() error {
return s.db.Close()
}
func (s *SQL) Lookup(val string) (string, bool, error) {
func (s *SQL) Lookup(ctx context.Context, val string) (string, bool, error) {
var repl string
row := s.lookup.QueryRow(val)
row := s.lookup.QueryRowContext(ctx, val)
if err := row.Scan(&repl); err != nil {
if err == sql.ErrNoRows {
return "", false, nil