stringify

package
v0.0.0-...-ce9259a Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fmt

func Fmt(vals ...any) []string

Fmt is an internal func that's currently exposed to get around some import dependencies. It runs the marshal func for all values provided to it, which will stringify the values according to the clues marshaler and concealer rules.

func Marshal

func Marshal(a any, shouldConceal bool) string

Marshal is the central marshalling handler for the entire package. All stringification of values comes down to this function. Priority for stringification follows this order: 1. nil -> "" 2. conceal all concealer interfaces 3. flat string values 4. string all stringer interfaces 5. fmt.sprintf the rest

func Normalize

func Normalize(kvs ...any) map[string]any

Normalize ensures that the variadic of key-value pairs is even in length, and then transforms that slice of values into a map[string]any, where all keys are transformed to string using the marshal() func.

Types

type Concealer

type Concealer interface {
	// Conceal produces an obfuscated representation of the value.
	Conceal() string
	// Concealers also need to comply with Format.
	// Complying with Conceal() alone doesn't guarantee that
	// the variable won't pass into fmt.Printf("%v") and skip
	// the whole conceal process.
	Format(fs fmt.State, verb rune)
	// PlainStringer is the opposite of conceal.
	// Useful for if you want to retrieve the raw value of a secret.
	PlainString() string
}

duplicated here from secrets to avoid import cycles. Since this is an internal package, we don't let end users see it.

Jump to

Keyboard shortcuts

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