mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 12:41:53 +08:00
refactor(services): 统一数据库插件的DBWrapper
4个数据库插件(MySQL、PostgreSQL、MSSQL、Oracle)都有相同的sql.DB包装代码, 合并为通用的SQLDBWrapper,减少重复。
This commit is contained in:
@@ -2,6 +2,7 @@ package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
@@ -369,3 +370,17 @@ func matchIgnoreCase(a, b string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// 通用数据库连接包装
|
||||
// =============================================================================
|
||||
|
||||
// SQLDBWrapper 包装 sql.DB 以实现 io.Closer
|
||||
// 用于 MySQL、PostgreSQL、MSSQL、Oracle 等数据库插件的连接返回
|
||||
type SQLDBWrapper struct {
|
||||
*sql.DB
|
||||
}
|
||||
|
||||
func (w *SQLDBWrapper) Close() error {
|
||||
return w.DB.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user