Use the go sql context functions (ExecContext, QueryContext etc...) The context is saved inside Tx so the library users should only pass it one time to the db.Do function.