pretty

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 6 Imported by: 1

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

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

func Env(obj any) string

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

func JSON(obj any) string

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

func JSONMasked(obj any) string

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

func MaskJSON(obj any) any

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

func YAML(obj any) string

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

func YAMLMasked(obj any) string

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.

Jump to

Keyboard shortcuts

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