Documentation
¶
Overview ¶
Package redact provides a simple way to redact sensitive information.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Environ = fn{func(values ...string) []string { env := os.Environ() oldNew := make([]string, 0, len(env)*2) for _, value := range env { name, _, _ := strings.Cut(value, "=") if v := os.Getenv(name); v != "" { oldNew = append(oldNew, v, defaultMask) } } return Redact(strings.NewReplacer(oldNew...).Replace, values) }}
Environ redacts values that contain environment variables.
View Source
var NoRedact = fn{func(values ...string) []string {
return values
}}
NoRedact does not redact values.
Functions ¶
Types ¶
type Redactor ¶
Redactor is an interface that redacts values.
func Use ¶
Use creates a new Redactor from a list of Redactors.
Example ¶
package main
import (
"fmt"
"os"
"go.nhat.io/redact"
)
func main() {
_ = os.Setenv("CUSTOM_ENV", "world") //nolint: errcheck
r := redact.Use(
redact.Environ,
redact.Values("hello"),
)
result := r.Redact("hello world!", "hello there")
for _, s := range result {
fmt.Println(s)
}
}
Output: ****** ******! ****** there
type Replacer ¶
Replacer is a string replacer that redacts values.
func NewReplacer ¶
NewReplacer creates a new Replacer that replaces the sensitive values with the mask.
Click to show internal directories.
Click to hide internal directories.
