repr

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT, MIT, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = New(os.Stdout, Indent("  "))

Default prints to os.Stdout with two space indentation.

Functions

func Print

func Print(vs ...any)

Print writes a representation of v to os.Stdout, separated by spaces.

func Println

func Println(vs ...any)

Println prints v to os.Stdout, one per line.

func String

func String(v any, options ...Option) string

String returns a string representing v.

Types

type Option

type Option func(o *Printer)

An Option modifies the default behaviour of a Printer.

func AlwaysIncludeType

func AlwaysIncludeType() Option

AlwaysIncludeType always includes explicit type information for each item.

func ExplicitTypes

func ExplicitTypes(ok bool) Option

ExplicitTypes adds explicit typing to slice and map struct values that would normally be inferred by Go.

func Hide

func Hide(ts ...any) Option

Hide excludes the given types from representation, instead just printing the name of the type.

func IgnoreGoStringer

func IgnoreGoStringer() Option

IgnoreGoStringer disables use of the .GoString() method.

func Indent

func Indent(indent string) Option

Indent output by this much.

func NoIndent

func NoIndent() Option

NoIndent disables indenting.

func OmitEmpty

func OmitEmpty(omitEmpty bool) Option

OmitEmpty sets whether empty field members should be omitted from output.

type Printer

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

Printer represents structs in a printable manner.

func New

func New(w io.Writer, options ...Option) *Printer

New creates a new Printer on w with the given Options.

func (*Printer) Print

func (p *Printer) Print(vs ...any)

Print the values.

func (*Printer) Println

func (p *Printer) Println(vs ...any)

Println prints each value on a new line.

Jump to

Keyboard shortcuts

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