xpretty

package module
v0.0.0-...-b154112 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: GPL-3.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RedPrintf    = color.New(color.FgRed, color.Bold).PrintfFunc()
	CyanPrintf   = color.New(color.FgCyan, color.Bold).PrintfFunc()
	YellowPrintf = color.New(color.FgYellow, color.Bold).PrintfFunc()
	GreenPrintf  = color.New(color.FgGreen, color.Bold).PrintfFunc()
)
View Source
var (
	RedPrintln    = color.New(color.FgRed, color.Bold).PrintlnFunc()
	CyanPrintln   = color.New(color.FgCyan, color.Bold).PrintlnFunc()
	YellowPrintln = color.New(color.FgYellow, color.Bold).PrintlnFunc()
	GreenPrintln  = color.New(color.FgGreen, color.Bold).PrintlnFunc()
)
View Source
var (
	Red     = color.New(color.FgRed, color.Bold).SprintFunc()
	Redf    = color.New(color.FgRed, color.Bold).SprintfFunc()
	Green   = color.New(color.FgGreen, color.Bold).SprintFunc()
	Greenf  = color.New(color.FgGreen, color.Bold).SprintfFunc()
	White   = color.New(color.FgHiWhite, color.Bold).SprintFunc()
	Whitef  = color.New(color.FgHiWhite, color.Bold).SprintfFunc()
	Yellow  = color.New(color.FgYellow, color.Bold).SprintFunc()
	Yellowf = color.New(color.FgYellow, color.Bold).SprintfFunc()
	Cyan    = color.New(color.FgCyan, color.Bold).SprintFunc()
	Cyanf   = color.New(color.FgCyan, color.Bold).SprintfFunc()
)
View Source
var (
	Redfu = color.New(color.FgRed, color.Bold, color.Underline).SprintfFunc()
	Redfc = color.New(color.FgRed, color.Bold, color.CrossedOut).SprintfFunc()
)

Redfu means red foreground with bold underline

View Source
var (
	Faint = color.New(color.Faint, color.FgWhite).SprintFunc()
	Info  = color.New(color.FgYellow, color.BgBlack, color.Bold).SprintFunc()
)

Functions

func Caller

func Caller(skip int) (string, int)

Caller wraps runtime.Caller and returns file and line number information

skip:

  • 0: Caller
  • 1: is where Caller is called

Returns: filename, linenum

func DLog

func DLog(skip int, cfn func(a ...interface{}) string, msg ...interface{})

func DummyErrorLog

func DummyErrorLog(msg ...interface{})

DummyErrorLog will print a dummy log with red bg

func DummyLog

func DummyLog(msg ...interface{})

DummyLog will print a dummy log with green bg

func DumpCallerStack

func DumpCallerStack()

func DumpCallerWithKey

func DumpCallerWithKey(args ...string)

DumpCallerStack

print the caller tree

func GetCallerStack

func GetCallerStack() string

func Initialize

func Initialize(opts ...XOptFunc)

Initialize setups

  • color: used for `terminal vivid output`, true by default
  • dummyLog: used in `DummyLog`, true by default

func InitializeWithColor

func InitializeWithColor(opts ...XOptFunc)

func JsonToYaml

func JsonToYaml(raw string) (string, error)

func MustJsonToYaml

func MustJsonToYaml(raw string) string

func MustPrettyYaml

func MustPrettyYaml(raw string, opts ...PrettyOptFunc)

func PrettyJson

func PrettyJson(rawJson string, opts ...PrettyOptFunc) error

func PrettyJsonArray

func PrettyJsonArray(rawJson string, opts ...PrettyOptFunc) error

func PrettyJsonAsYaml

func PrettyJsonAsYaml(rawJson string, opts ...PrettyOptFunc)

func PrettyMap

func PrettyMap(obj map[string]interface{}, opts ...PrettyOptFunc) error

func PrettyYaml

func PrettyYaml(rawYaml string, opts ...PrettyOptFunc) error

func RecoverAndDumpOnly

func RecoverAndDumpOnly()

func RecoverWithCb

func RecoverWithCb(cb func())

func SetNoColor

func SetNoColor(b bool)

Types

type PrettyOptFunc

type PrettyOptFunc func(o *PrettyOpts)

func WithFilterKey

func WithFilterKey(s string) PrettyOptFunc

func WithIndent

func WithIndent(i int) PrettyOptFunc

func WithLineNumber

func WithLineNumber(b bool) PrettyOptFunc

type PrettyOpts

type PrettyOpts struct {
	// contains filtered or unexported fields
}

type XOptFunc

type XOptFunc func(o *XOpts)

func WithDummyLog

func WithDummyLog(b bool) XOptFunc

func WithNoColor

func WithNoColor(b bool) XOptFunc

type XOpts

type XOpts struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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