GenerateRequestID creates a new 8-character hex request ID.
()
| 16 | |
| 17 | // GenerateRequestID creates a new 8-character hex request ID. |
| 18 | func GenerateRequestID() string { |
| 19 | b := make([]byte, 4) |
| 20 | if _, err := rand.Read(b); err != nil { |
| 21 | return "00000000" |
| 22 | } |
| 23 | return hex.EncodeToString(b) |
| 24 | } |
| 25 | |
| 26 | // WithRequestID returns a new context with the request ID attached. |
| 27 | func WithRequestID(ctx context.Context, requestID string) context.Context { |