From d73621cfdd46e529f53e366c4cb1a32477360853 Mon Sep 17 00:00:00 2001 From: hupeh Date: Wed, 25 Oct 2023 17:47:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/db/db.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/db/db.go b/pkg/db/db.go index a1d4b4d..c65a4ce 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -1,6 +1,7 @@ package db import ( + "context" "database/sql" "errors" "gorm.io/driver/mysql" @@ -69,6 +70,10 @@ func DB() *gorm.DB { return db } +func WithContext(ctx context.Context) *gorm.DB { + return DB().WithContext(ctx) +} + // SetDB 自定义操作引擎 func SetDB(engine *gorm.DB) { lock.Lock()