mask

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mask hides sensitive values, for logs and other output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Full

func Full[S ~string](S) S

Full replaces s with a mask of fixed length.

func Hash

func Hash[S ~string](s S) S

Hash replaces s with the start of its SHA-256 in hex, so equal values stay equal in logs.

func LogValue

func LogValue(v any) slog.Value

LogValue gives slog the JSON of v: an object is a group with its keys in order, an array a list, anything else its value. A value without JSON gives the error text.

func Map

func Map[T interface{ Masked() T }](m map[string]T) map[string]T

Map returns a copy of m with each value masked.

func Partial

func Partial[S ~string](s S, prefix, suffix int) S

Partial keeps prefix characters at the start of s and suffix at the end, and masks the rest. A value too short to hide anything is masked in full.

func Regex

func Regex[S ~string](s S, re *regexp.Regexp) S

Regex replaces each character of the parts of s that re matches with *.

func Slice

func Slice[T interface{ Masked() T }](s []T) []T

Slice returns a copy of s with each item masked.

func Zero

func Zero[T any](T) T

Zero returns the zero value of the type of v, for a sensitive value that is no string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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