redact

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package redact scrubs secrets from text destined for logs and errors.

A Redactor replaces secrets registered at run time (the values the host sends in initialize) and anything that looks like a well-known key format.

Index

Constants

View Source
const MinSecretLen = 8

MinSecretLen is the shortest secret, in runes, that Add accepts.

View Source
const Replacement = "‹redacted›"

Replacement is written in place of every secret.

Variables

This section is empty.

Functions

This section is empty.

Types

type Redactor

type Redactor struct {
	// contains filtered or unexported fields
}

Redactor replaces registered secrets and well-known key formats. It is safe for concurrent use. A nil *Redactor is valid and applies only the patterns.

func New

func New() *Redactor

New returns a Redactor with no registered secrets.

func (*Redactor) Add

func (r *Redactor) Add(secret string)

Add registers a secret. Secrets shorter than MinSecretLen runes are ignored, because replacing short strings would corrupt ordinary text. Only the literal value is registered, not its JSON-escaped or URL-encoded form.

func (*Redactor) String

func (r *Redactor) String(s string) string

String returns s with every registered secret and every recognised key format replaced by Replacement.

Jump to

Keyboard shortcuts

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