id.go 203 B

123456789101112131415
  1. package log
  2. import (
  3. "context"
  4. "math/rand"
  5. )
  6. type idContext struct {
  7. context.Context
  8. id uint32
  9. }
  10. func ContextWithID(ctx context.Context) context.Context {
  11. return &idContext{ctx, rand.Uint32()}
  12. }