Skip to content

Commit

Permalink
remove label and use slices.Contains (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvndaai authored Oct 24, 2024
1 parent 71916fd commit f681740
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions ctxerr.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import (
"log"
"path/filepath"
"runtime"
"slices"
"strings"

"github.com/mvndaai/ctxerr/joinederr"
Expand Down Expand Up @@ -402,17 +403,14 @@ func (in Instance) AllFields(err error) map[string]any {
fields[k] = v
}
}
OUTER:
for k, v := range fields {
for _, sk := range in.FieldsAsSlice {
if k == sk {
if _, ok := f[k]; !ok {
f[k] = []any{}
}

f[k] = append(f[k].([]any), v)
continue OUTER
if slices.Contains(in.FieldsAsSlice, k) {
if _, ok := f[k]; !ok {
f[k] = []any{}
}

f[k] = append(f[k].([]any), v)
continue
}
f[k] = v
}
Expand Down

0 comments on commit f681740

Please sign in to comment.