Skip to content

Commit

Permalink
chore: Change some type checks to use stringer
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Oct 25, 2023
1 parent 5541b78 commit 34e7a31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/command/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func (j Builder) String() string {
switch v := v.(type) {
case string:
buf.WriteString(shellescape.Quote(v))
case Env:
buf.WriteString(v.String())
case Raw:
buf.WriteString(string(v))
case fmt.Stringer:
buf.WriteString(v.String())
default:
panic(fmt.Errorf("unknown value in command: %#v", v))
}
Expand Down
6 changes: 2 additions & 4 deletions internal/log_hooks/redact.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ func (r Redact) Fire(entry *log.Entry) error {
switch field := field.(type) {
case string:
entry.Data[i] = strings.ReplaceAll(field, string(r), "***")
default:
if field, ok := field.(fmt.Stringer); ok {
entry.Data[i] = strings.ReplaceAll(field.String(), string(r), "***")
}
case fmt.Stringer:
entry.Data[i] = strings.ReplaceAll(field.String(), string(r), "***")
}
}
return nil
Expand Down

0 comments on commit 34e7a31

Please sign in to comment.