master v1.0.4
李光春 2 years ago
parent 307d77115c
commit 6de48c55c7

@ -1,3 +1,3 @@
package gotrace_id
const Version = "1.0.3"
const Version = "1.0.4"

@ -23,5 +23,8 @@ func GetTraceIdContext(ctx context.Context) string {
if len(traceId) <= 0 {
return ""
}
if traceId == "%!s(<nil>)" {
return ""
}
return traceId
}

@ -1,11 +1,15 @@
package gotrace_id
import (
"context"
"testing"
)
func TestContext(t *testing.T) {
ctx := CustomTraceIdContext()
t.Log(ctx)
t.Log(GetTraceIdContext(ctx))
ctx1 := CustomTraceIdContext()
t.Log(ctx1)
t.Log(GetTraceIdContext(ctx1))
ctx2 := context.Background()
t.Log(ctx2)
t.Log(GetTraceIdContext(ctx2))
}

@ -25,5 +25,8 @@ func GetGinTraceId(c *gin.Context) string {
if len(traceId) <= 0 {
return ""
}
if traceId == "%!s(<nil>)" {
return ""
}
return traceId
}

Loading…
Cancel
Save