Documentation
¶
Overview ¶
Package redact provides a string type for secrets that refuses to reveal itself in logs, errors, JSON/YAML, or fmt output. Wrap every credential field in Secret so an accidental %v, slog attribute, or config dump prints the placeholder instead of the secret. Call Reveal only at the exact point the secret is used.
Index ¶
- Constants
- type Secret
- func (s Secret) GoString() string
- func (s Secret) IsZero() bool
- func (s Secret) LogValue() slog.Value
- func (s Secret) MarshalJSON() ([]byte, error)
- func (s Secret) MarshalText() ([]byte, error)
- func (s Secret) MarshalYAML() (any, error)
- func (s Secret) Reveal() string
- func (s Secret) String() string
Constants ¶
const Placeholder = "[REDACTED]"
Placeholder is what a redacted secret renders as in any output.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Secret ¶
type Secret string
Secret is a string whose value never appears in formatted output.
func (Secret) LogValue ¶
LogValue implements slog.LogValuer so structured logs never capture the secret.
func (Secret) MarshalJSON ¶
MarshalJSON ensures JSON encoders emit the placeholder.
func (Secret) MarshalText ¶
MarshalText covers fmt and any encoding that honors encoding.TextMarshaler.
func (Secret) MarshalYAML ¶
MarshalYAML ensures yaml.v3 encoders emit the placeholder.