Compare commits

..

2 Commits

Author SHA1 Message Date
zhaoyupeng
f67d78b5e6 Merge remote-tracking branch 'origin/master' 2025-06-13 16:11:14 +08:00
zhaoyupeng
f217055e4a feat: tool ctx add trace 2025-06-13 16:10:20 +08:00

View File

@ -2,6 +2,8 @@ package tool
import ( import (
"context" "context"
"fmt"
"gitea.loveuer.com/yizhisec/packages/opt"
"time" "time"
) )
@ -21,7 +23,7 @@ func Timeout(seconds ...int) (ctx context.Context) {
return return
} }
func TimeoutCtx(ctx context.Context, seconds ...int) context.Context { func CtxTimeout(ctx context.Context, seconds ...int) context.Context {
var ( var (
duration time.Duration duration time.Duration
) )
@ -36,3 +38,7 @@ func TimeoutCtx(ctx context.Context, seconds ...int) context.Context {
return nctx return nctx
} }
func CtxTrace(ctx context.Context, key string) context.Context {
return context.WithValue(ctx, opt.TraceKey, fmt.Sprintf("%36s", key))
}