redact

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Overview

Package redact removes credentials from URLs before they are placed in errors or logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URL

func URL(u *url.URL) string

URL returns a string representation of u that is safe to log:

  • any userinfo component is dropped entirely;
  • any query parameter whose name matches isSensitiveQueryKey has its value replaced with the literal "***";
  • the fragment is dropped because it may contain credentials;
  • the path, scheme, host, port, and non-sensitive query values are preserved so operators can still identify the endpoint.

The original *url.URL is not mutated.

func URLError

func URLError(err error) error

URLError returns a copy of the *url.Error in err's chain with its URL and any nested *url.Error values redacted. The copies keep Op and the underlying causes, so errors.Is and errors.As still reach them. Pass errors returned directly by net/http or net/url: wrapping around the outer *url.Error is not preserved. Errors without a *url.Error are returned unchanged.

func URLString

func URLString(raw string) string

URLString parses raw and returns the redacted form. If parsing fails it splits raw the same way net/url does: the fragment is dropped, sensitive query values are masked, and userinfo is removed from the authority only, so an "@" in the path or query is left alone.

Types

This section is empty.

Jump to

Keyboard shortcuts

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