/
pyo
/
updater
Обзор
Документация
Войти
/
pyo
/
updater
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
pkg/util/context.go
23 строки
366 B
ilovepitsa
restore from another repo
16 июн 2025, 13:25
16 июн 2025, 13:25
d7455bb
Код
Авторство
О чём код?
package util import ( "context" "github.com/jackc/pgx/v5" ) func TxToContext(ctx context.Context, tx pgx.Tx) context.Context { return context.WithValue(ctx, txCtxPoolKey, tx) } type txCtxKey struct{} var txCtxPoolKey = txCtxKey{} func TxFromCtx(ctx context.Context) pgx.Tx { tx, ok := ctx.Value(txCtxPoolKey).(pgx.Tx) if ok { return tx } return nil }