From 34e7a31416a799d04f24ac37ae59588ff8f59f22 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 25 Oct 2023 14:05:32 -0500 Subject: [PATCH] chore: Change some type checks to use stringer --- internal/command/builder.go | 4 ++-- internal/log_hooks/redact.go | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/command/builder.go b/internal/command/builder.go index 437a2f16..a76163a3 100644 --- a/internal/command/builder.go +++ b/internal/command/builder.go @@ -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)) } diff --git a/internal/log_hooks/redact.go b/internal/log_hooks/redact.go index 3697a154..d8a5618a 100644 --- a/internal/log_hooks/redact.go +++ b/internal/log_hooks/redact.go @@ -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