Skip to content

Commit

Permalink
Fix taking value of type of input, rather than value of input
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Nov 28, 2024
1 parent d003119 commit 027d067
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions internal/data/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,14 @@ func RegisterEventListener[T any](path string, isPrefix bool, f func(key string,

func redact[T any](input T) (redacted []byte) {

current := reflect.TypeOf(input)
if current.Kind() == reflect.Pointer {
current = current.Elem()
}

values := reflect.ValueOf(current)
values := reflect.ValueOf(input)
if values.Kind() == reflect.Pointer {
values = values.Elem()
}

if current.Kind() == reflect.Struct {
for i := 0; i < current.NumField(); i++ {
_, isSensitive := current.Field(i).Tag.Lookup("sensitive")
if values.Kind() == reflect.Struct {
for i := 0; i < values.NumField(); i++ {
_, isSensitive := values.Type().Field(i).Tag.Lookup("sensitive")
if isSensitive {
if values.Field(i).CanSet() {
values.Field(i).SetZero()
Expand Down

0 comments on commit 027d067

Please sign in to comment.