context_test.go 301 B

123456789101112131415
  1. package test
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. )
  7. func TestContest(t *testing.T) {
  8. ctx := context.Background()
  9. ctx = context.WithValue(ctx, "traceId", "qcrao-2019")
  10. ctx = context.WithValue(ctx, "traceId2", "qcrao-2020")
  11. fmt.Println(ctx.Value("traceId"))
  12. fmt.Println(ctx.Value("traceId2"))
  13. }