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

@ -1,3 +1,3 @@
package gotrace_id 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 { if len(traceId) <= 0 {
return "" return ""
} }
if traceId == "%!s(<nil>)" {
return ""
}
return traceId return traceId
} }

@ -1,11 +1,15 @@
package gotrace_id package gotrace_id
import ( import (
"context"
"testing" "testing"
) )
func TestContext(t *testing.T) { func TestContext(t *testing.T) {
ctx := CustomTraceIdContext() ctx1 := CustomTraceIdContext()
t.Log(ctx) t.Log(ctx1)
t.Log(GetTraceIdContext(ctx)) 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 { if len(traceId) <= 0 {
return "" return ""
} }
if traceId == "%!s(<nil>)" {
return ""
}
return traceId return traceId
} }

Loading…
Cancel
Save