package model import ( "context" "gorm.io/gorm" ) func withTx(ctx context.Context, conn, tx *gorm.DB) *gorm.DB { if tx != nil { return tx } else { return conn.WithContext(ctx) } }