diff --git a/errors_test.go b/errors_test.go index 4c0efbd..f90b3dd 100644 --- a/errors_test.go +++ b/errors_test.go @@ -55,6 +55,13 @@ func TestV(t *testing.T) { eqV(t, err, "str", "wrapped") }) + + t.Run("when provided KVs should incorporate them as they are without key mapping", func(t *testing.T) { + err := errors.New("simple msg", errors.KVs(errors.KVs("unspread", "vals"), errors.KV{K: "indiv", V: "1"})) + + eqV(t, err, "unspread", "vals") + eqV(t, err, "indiv", "1") + }) } func eq[T comparable](t *testing.T, want, got T) bool { diff --git a/options.go b/options.go index e529292..fe0c374 100644 --- a/options.go +++ b/options.go @@ -82,6 +82,14 @@ func KVs(fields ...any) []KV { for i := 0; i < len(fields); i += 2 { var kv KV switch t := fields[i].(type) { + case []KV: + out = append(out, t...) + i-- + continue + case KV: + out = append(out, t) + i-- + continue case string: kv.K = t case fmt.Stringer: