style(go): 合并连续变量声明并明确规范约束

This commit is contained in:
zhangdeman committed 2026-11-27 23:36:02 -08:00
1 parent 2492251a89
commit 5287321ca2
8 files changed
+42 -126

No files matched your search

+11 -33
View File
@@ -46,9 +46,7 @@ func (h *Hook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
return func(ctx context.Context, cmd redis.Cmder) error {
var (
begin = time.Now()
)
var (
err = next(ctx, cmd)
err = next(ctx, cmd)
)
h.record(ctx, cmd, time.Since(begin), err)
return err
@@ -61,12 +59,8 @@ func (h *Hook) ProcessHook(next redis.ProcessHook) redis.ProcessHook {
func (h *Hook) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.ProcessPipelineHook {
return func(ctx context.Context, cmds []redis.Cmder) error {
var (
begin = time.Now()
)
var (
err = next(ctx, cmds)
)
var (
begin = time.Now()
err = next(ctx, cmds)
elapsed = time.Since(begin)
)
for _, cmd := range cmds {
@@ -80,31 +74,15 @@ func (h *Hook) ProcessPipelineHook(next redis.ProcessPipelineHook) redis.Process
// 入参:ctx 为可信诊断上下文,cmd 为原生命令,elapsed 为执行耗时,resultErr 为当前命令真实结果。
func (h *Hook) record(ctx context.Context, cmd redis.Cmder, elapsed time.Duration, resultErr error) {
var (
args = cmd.Args()
)
var (
result any
)
var (
args = cmd.Args()
result any
loggedArgs any
)
var (
hidden bool
)
var (
status = "success"
)
var (
name = strings.ToLower(cmd.Name())
)
var (
method reflect.Value
)
var (
values []reflect.Value
)
var (
fields []zap.Field
hidden bool
status = "success"
name = strings.ToLower(cmd.Name())
method reflect.Value
values []reflect.Value
fields []zap.Field
)
if h.logger == nil {
return
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.