redact

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

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

View Source
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) GoString

func (s Secret) GoString() string

func (Secret) IsZero

func (s Secret) IsZero() bool

IsZero reports whether the secret is empty.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue implements slog.LogValuer so structured logs never capture the secret.

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON ensures JSON encoders emit the placeholder.

func (Secret) MarshalText

func (s Secret) MarshalText() ([]byte, error)

MarshalText covers fmt and any encoding that honors encoding.TextMarshaler.

func (Secret) MarshalYAML

func (s Secret) MarshalYAML() (any, error)

MarshalYAML ensures yaml.v3 encoders emit the placeholder.

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the underlying secret value. Call only where the secret is actually used (auth, signing); never pass the result to logging or error wrapping.

func (Secret) String

func (s Secret) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL