Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mizutani committed Feb 23, 2025
1 parent 908457d commit 6c9adfe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions redactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func RedactString(redact func(s string) string) Redactor {
return true
}

// If the source value is `any`, not nil and string, it should be redacted.
if src.Kind() == reflect.Interface && !src.IsNil() {
elem := src.Elem()
if elem.Kind() == reflect.String {
redacted := redact(elem.String())
// Destination value is also `any`, so it should use `Set` to set the redacted string value instead of `SetString`.
dst.Elem().Set(reflect.ValueOf(redacted))
return true
}
Expand Down

0 comments on commit 6c9adfe

Please sign in to comment.