repr

package
v3.2.12 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT, MIT, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package repr

Some values (such as pointers to basic types) can not be represented directly in Go. These values will be output as `&<value>`. eg. `&23`

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 ...interface{})

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

func Println

func Println(vs ...interface{})

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

func String

func String(v interface{}, 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 ...interface{}) 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 ...interface{})

Print the values.

func (*Printer) Println

func (p *Printer) Println(vs ...interface{})

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