IDFromCtx returns the unique id associated to the context if any.
(ctx context.Context)
| 193 | |
| 194 | // IDFromCtx returns the unique id associated to the context if any. |
| 195 | func IDFromCtx(ctx context.Context) (id xid.ID, ok bool) { |
| 196 | id, ok = ctx.Value(idKey{}).(xid.ID) |
| 197 | return |
| 198 | } |
| 199 | |
| 200 | // CtxWithID adds the given xid.ID to the context |
| 201 | func CtxWithID(ctx context.Context, id xid.ID) context.Context { |