(ctx context.Context, keyAndValue ...any)
| 146 | } |
| 147 | |
| 148 | func ContentWithValues(ctx context.Context, keyAndValue ...any) context.Context { |
| 149 | if len(keyAndValue) < 1 || len(keyAndValue)%2 != 0 { |
| 150 | panic("keyAndValue must be an even number of arguments (key, value, ...)") |
| 151 | } |
| 152 | for len(keyAndValue) > 0 { |
| 153 | ctx = context.WithValue(ctx, keyAndValue[0], keyAndValue[1]) |
| 154 | keyAndValue = keyAndValue[2:] |
| 155 | } |
| 156 | return ctx |
| 157 | } |