master v1.0.12
dtapps 1 month ago
parent ab6de721a6
commit e9c2aa60d0

@ -13,5 +13,5 @@
#### 安装
```shell
go get -v -u go.dtapp.net/gotrace_id@v1.0.11
go get -v -u go.dtapp.net/gotrace_id@v1.0.12
```

@ -6,4 +6,5 @@ const (
TraceIdKey = "trace_id"
TraceIdGinKey = "trace_id"
TraceIdRequestKey = "X-Request-Id"
TraceIDRequestKey = "X-Request-ID"
)

@ -26,7 +26,12 @@ func SetGinTraceIdContext(ctx context.Context, c *gin.Context) context.Context {
// GetTraceIdContext 通过上下文获取跟踪编号
func GetTraceIdContext(ctx context.Context) string {
traceId := fmt.Sprintf("%s", ctx.Value(TraceIdKey))
return CustomGetTraceIdContext(ctx, TraceIdKey)
}
// CustomGetTraceIdContext 通过自定义上下文获取跟踪编号
func CustomGetTraceIdContext(ctx context.Context, key string) string {
traceId := fmt.Sprintf("%s", ctx.Value(key))
if traceId == Nil {
return ""
}

@ -1,3 +1,3 @@
package gotrace_id
const Version = "1.0.11"
const Version = "1.0.12"

Loading…
Cancel
Save