Documentation
¶
Overview ¶
Package pretty contains functions for prettifying and visualizing data in JSON YAML, and ENV formats. Includes support for masking sensitive fields when outputting data, if appropriately tagged.
Index ¶
- func DefaultYAMLOptions() []yaml.EncodeOption
- func Env(obj any) string
- func JSON(obj any) string
- func JSONMasked(obj any) string
- func MaskJSON(obj any) any
- func PrintDefault(env any)
- func PrintEnv(env any)
- func PrintJSON(obj any)
- func PrintJSONMasked(obj any)
- func PrintYAML(obj any)
- func PrintYAMLMasked(obj any)
- func YAML(obj any) string
- func YAMLMasked(obj any) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultYAMLOptions ¶ added in v0.1.0
func DefaultYAMLOptions() []yaml.EncodeOption
DefaultYAMLOptions defines the default YAML encoding options for pretty printing.
func Env ¶ added in v0.0.11
Env formats data as environment variables. Converts any value to KEY=VALUE format suitable for .env files. Complex objects are flattened to string representations.
func JSON ¶
JSON formats data as indented JSON. Converts any value to a formatted JSON string with consistent indentation. Returns error message as string if marshaling fails.
func JSONMasked ¶
JSONMasked formats data as JSON with sensitive data masked. Converts any value to JSON, first applying masking rules to hide sensitive fields like passwords and tokens.
func MaskJSON ¶
MaskJSON applies data masking rules to an object. Uses predefined rules to identify and mask sensitive fields, replacing them with "-" characters. Returns the masked object or error message if masking fails.
func PrintDefault ¶ added in v0.0.13
func PrintDefault(env any)
PrintDefault outputs the default representation of any value.
func PrintEnv ¶ added in v0.0.11
func PrintEnv(env any)
PrintEnv outputs environment variables to stdout. Prints any value in KEY=VALUE format suitable for .env files.
func PrintJSON ¶
func PrintJSON(obj any)
PrintJSON outputs formatted JSON to stdout. Prints any value as indented JSON with consistent formatting.
func PrintJSONMasked ¶
func PrintJSONMasked(obj any)
PrintJSONMasked outputs masked JSON to stdout. Prints any value as JSON with sensitive fields masked for security. Uses MaskJSON internally for field masking.
func PrintYAML ¶
func PrintYAML(obj any)
PrintYAML outputs formatted YAML to stdout. Prints any value as indented YAML with consistent formatting.
func PrintYAMLMasked ¶
func PrintYAMLMasked(obj any)
PrintYAMLMasked outputs masked YAML to stdout. Prints any value as YAML with sensitive fields masked for security. Uses MaskYAML internally for field masking.
func YAML ¶
YAML formats data as indented YAML. Converts any value to a formatted YAML string with consistent indentation. Returns error message as string if encoding fails.
func YAMLMasked ¶
YAMLMasked formats data as YAML with sensitive data masked. Converts any value to YAML, first applying masking rules to hide sensitive fields. Uses JSONMasked internally for masking.
Types ¶
This section is empty.