pretty

package module
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 19 Imported by: 3

README

Pretty

Go pretty print library.

Go Reference

Features

Usage

Example

Documentation

Overview

Package pretty provides a pretty-printer.

Example
type exampleStruct struct {
	Int    int
	Float  float64
	String string
	Map    map[string]int
	Slice  []int
}
v := exampleStruct{
	Int:    123,
	Float:  123.456,
	String: "test",
	Map: map[string]int{
		"foo": 1,
		"bar": 2,
	},
	Slice: []int{1, 2, 3},
}
s := String(v)
fmt.Println(s)
Output:
[github.com/pierrre/pretty.exampleStruct] {
	Int: [int] 123,
	Float: [float64] 123.456,
	String: [string] (len=4) "test",
	Map: [map[string]int] (len=2) {
		"bar": 2,
		"foo": 1,
	},
	Slice: [[]int] (len=3) {
		1,
		2,
		3,
	},
}

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultPrinter = NewPrinter(DefaultWriter)

DefaultPrinter is the default Printer.

It uses DefaultWriter.

View Source
var DefaultWriter = NewCommonWriter()

DefaultWriter is the default CommonWriter.

It is configured with CommonWriter.ConfigureTest and testing.Testing.

Functions

func FilterTypes added in v0.22.0

func FilterTypes(typs ...reflect.Type) func(typ reflect.Type) bool

FilterTypes returns a new FilterWriter filter function that returns true if the type is in the given list or if it implements any of the given interface types.

func Formatter

func Formatter(vi any) fmt.Formatter

Formatter returns a fmt.Formatter for the value with DefaultPrinter.

Example
f := Formatter("test")
s := fmt.Sprintf("%v", f)
fmt.Println(s)
Output:
[string] (len=4) "test"

func String

func String(vi any) string

String returns the value as a string with DefaultPrinter.

Example
s := String("test")
fmt.Println(s)
Output:
[string] (len=4) "test"

func Vars added in v0.21.5

func Vars(vs ...any) []any

Vars returns a slices of variadic arguments. It allows to call a Printer with the result of a function returning multiple values.

func Write

func Write(w io.Writer, vi any)

Write writes the value to the io.Writer with DefaultPrinter.

Example
buf := new(bytes.Buffer)
Write(buf, "test")
s := buf.String()
fmt.Println(s)
Output:
[string] (len=4) "test"

func WriteErr added in v0.15.0

func WriteErr(w io.Writer, vi any) error

WriteErr writes the value to the io.Writer with DefaultPrinter, and returns an error if it occurs.

Types

type ArrayWriter added in v0.15.0

type ArrayWriter struct {
	ValueWriter
	// ShowIndexes shows the indexes.
	// Default: false.
	ShowIndexes bool
	// MaxLen is the maximum length of the array.
	// Default: 0 (no limit).
	MaxLen int
}

ArrayWriter is a ValueWriter that handles array values.

It should be created with NewArrayWriter.

func NewArrayWriter added in v0.15.0

func NewArrayWriter(vw ValueWriter) *ArrayWriter

NewArrayWriter creates a new ArrayWriter with default values.

func (*ArrayWriter) Supports added in v0.15.0

func (vw *ArrayWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ArrayWriter) WriteValue added in v0.15.0

func (vw *ArrayWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type BoolWriter added in v0.15.0

type BoolWriter struct{}

BoolWriter is a ValueWriter that handles bool values.

It should be created with NewBoolWriter.

func NewBoolWriter added in v0.15.0

func NewBoolWriter() *BoolWriter

NewBoolWriter creates a new BoolWriter.

func (*BoolWriter) Supports added in v0.15.0

func (vw *BoolWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*BoolWriter) WriteValue added in v0.15.0

func (vw *BoolWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ByTypeWriters added in v0.15.0

type ByTypeWriters map[reflect.Type]ValueWriter

ByTypeWriters is a ValueWriter that selects a ValueWriter by reflect.Type.

It should be created with NewByTypeWriters.

func NewByTypeWriters added in v0.15.0

func NewByTypeWriters() ByTypeWriters

NewByTypeWriters creates a new ByTypeWriters.

func (ByTypeWriters) Supports added in v0.15.0

func (vws ByTypeWriters) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (ByTypeWriters) WriteValue added in v0.15.0

func (vws ByTypeWriters) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type BytesHexDumpWriter added in v0.15.0

type BytesHexDumpWriter struct {
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowCap shows the cap.
	// Default: true.
	ShowCap bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// MaxLen is the maximum length of the bytes.
	// Default: 0 (no limit).
	MaxLen int
}

BytesHexDumpWriter is a ValueWriter that handles []byte and writes them with hex.Dumper.

It should be created with NewBytesHexDumpWriter.

func NewBytesHexDumpWriter added in v0.15.0

func NewBytesHexDumpWriter() *BytesHexDumpWriter

NewBytesHexDumpWriter creates a new BytesHexDumpWriter.

func (*BytesHexDumpWriter) Supports added in v0.15.0

func (vw *BytesHexDumpWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*BytesHexDumpWriter) WriteValue added in v0.15.0

func (vw *BytesHexDumpWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type Bytesable added in v0.2.0

type Bytesable interface {
	Bytes() []byte
}

Bytesable is an interface that can return a []byte.

type BytesableHexDumpWriter added in v0.15.0

type BytesableHexDumpWriter struct {
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowCap shows the cap.
	// Default: true.
	ShowCap bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// MaxLen is the maximum length of the bytes.
	// Default: 0 (no limit).
	MaxLen int
}

BytesableHexDumpWriter is a ValueWriter that handles Bytesable and writes thems with hex.Dumper.

If [Bytesable.Bytes] panics, BytesableHexDumpWriter.WriteValue returns false.

It should be created with NewBytesableHexDumpWriter.

func NewBytesableHexDumpWriter added in v0.15.0

func NewBytesableHexDumpWriter() *BytesableHexDumpWriter

NewBytesableHexDumpWriter creates a new BytesableHexDumpWriter.

func (*BytesableHexDumpWriter) Supports added in v0.15.0

func (vw *BytesableHexDumpWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*BytesableHexDumpWriter) WriteValue added in v0.15.0

func (vw *BytesableHexDumpWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type CanInterfaceWriter added in v0.15.0

type CanInterfaceWriter struct {
	ValueWriter
}

CanInterfaceWriter is a ValueWriter that attempts to convert the reflect.Value so it can be used with reflect.Value.Interface.

It should be created with NewCanInterfaceWriter.

func NewCanInterfaceWriter added in v0.15.0

func NewCanInterfaceWriter(vw ValueWriter) *CanInterfaceWriter

NewCanInterfaceWriter creates a new CanInterfaceValueWriter.

func (*CanInterfaceWriter) WriteValue added in v0.15.0

func (vw *CanInterfaceWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ChanWriter added in v0.15.0

type ChanWriter struct {
	ValueWriter
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowCap shows the cap.
	// Default: true.
	ShowCap bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// ShowElems shows the elements.
	// It reads the elements from the channel and put them back.
	// If the channel is closed, it doesn't put the elements back to the channel.
	// It only works with bidirectional channels.
	// Default: false.
	ShowElems bool
	// ShowIndexes shows the indexes.
	// Default: false.
	ShowIndexes bool
	// MaxLen is the maximum length of the channel.
	// Default: 0 (no limit).
	MaxLen int
}

ChanWriter is a ValueWriter that handles chan values.

It should be created with NewChanWriter.

func NewChanWriter added in v0.15.0

func NewChanWriter(vw ValueWriter) *ChanWriter

NewChanWriter creates a new ChanWriter with default values.

func (*ChanWriter) Supports added in v0.15.0

func (vw *ChanWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ChanWriter) WriteValue added in v0.15.0

func (vw *ChanWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type CommonWriter added in v0.15.0

type CommonWriter struct {
	UnwrapInterface  *UnwrapInterfaceWriter
	Recursion        *RecursionWriter
	MaxDepth         *MaxDepthWriter
	CanInterface     *CanInterfaceWriter
	Type             *TypeWriter
	ByType           ByTypeWriters
	ValueWriters     ValueWriters
	Support          *SupportWriter
	Time             *TimeWriter
	BytesHexDump     *BytesHexDumpWriter
	MathBig          *MathBigWriter
	Reflect          *ReflectWriter
	WeakPointer      *WeakPointerWriter
	Iter             *IterWriter
	Range            *FilterWriter[*RangeWriter]
	Error            *FilterWriter[*ErrorWriter]
	BytesableHexDump *FilterWriter[*BytesableHexDumpWriter]
	GoStringer       *FilterWriter[*GoStringerWriter]
	Stringer         *FilterWriter[*StringerWriter]
	Kind             *KindWriter
}

CommonWriter is a ValueWriter with common ValueWriter.

Any ValueWriter can be configured, and can be set to nil in order to disable it.

It should be created with NewCommonWriter.

func NewCommonWriter added in v0.15.0

func NewCommonWriter() *CommonWriter

NewCommonWriter creates a new CommonWriter initialized with default values.

func (*CommonWriter) ConfigureTest added in v0.15.0

func (vw *CommonWriter) ConfigureTest(enabled bool)

ConfigureTest configures the CommonWriter for testing.

It makes the result deterministic. It sorts the keys of maps and disables the address/capacity. The enabled boolean is used to enable or disable the configuration.

func (*CommonWriter) SetShowAddr added in v0.15.0

func (vw *CommonWriter) SetShowAddr(show bool)

SetShowAddr sets ShowAddr on all ValueWriter that supports it.

func (*CommonWriter) SetShowCap added in v0.15.0

func (vw *CommonWriter) SetShowCap(show bool)

SetShowCap sets ShowCap on all ValueWriter that supports it.

func (*CommonWriter) SetShowIndexes added in v0.15.0

func (vw *CommonWriter) SetShowIndexes(show bool)

SetShowIndexes sets ShowIndexes on all ValueWriter that supports it.

func (*CommonWriter) SetShowLen added in v0.15.0

func (vw *CommonWriter) SetShowLen(show bool)

SetShowLen sets ShowLen on all ValueWriter that supports it.

func (*CommonWriter) Supports added in v0.16.0

func (vw *CommonWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*CommonWriter) WriteValue added in v0.15.0

func (vw *CommonWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ComplexWriter added in v0.15.0

type ComplexWriter struct {
	// Format is the format used to format the complex.
	// Default: 'g'.
	Format byte
	// Precision is the precision used to format the complex.
	// Default: -1.
	Precision int
}

ComplexWriter is a ValueWriter that handles complex values.

It should be created with NewComplexWriter.

func NewComplexWriter added in v0.15.0

func NewComplexWriter() *ComplexWriter

NewComplexWriter creates a new ComplexWriter with default values.

func (*ComplexWriter) Supports added in v0.15.0

func (vw *ComplexWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ComplexWriter) WriteValue added in v0.15.0

func (vw *ComplexWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ErrorWriter added in v0.15.0

type ErrorWriter struct {
	ValueWriter
	// ShowVerbose indicates whether to show verbose error messages of errors implementing [VerboseError].
	// Default: true.
	ShowVerbose bool
	// ShowStack indicates whether to show stack frames of errors implementing [StackFramesError].
	// Default: true.
	ShowStack bool
	// Writers is a list of custom functions that are called when an error is written.
	// Default: nil.
	Writers []func(st *State, err error)
}

ErrorWriter is a ValueWriter that handles errors.

It writes the error's message, then the custom function, then the unwrapped error(s) if any.

It should be created with NewErrorWriter.

func NewErrorWriter added in v0.15.0

func NewErrorWriter(vw ValueWriter) *ErrorWriter

NewErrorWriter creates a new ErrorWriter with default values.

func (*ErrorWriter) Supports added in v0.15.0

func (vw *ErrorWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ErrorWriter) WriteStackFramesError added in v0.21.1

func (vw *ErrorWriter) WriteStackFramesError(st *State, err error)

WriteStackFramesError writes the stack frames of an error that implements StackFramesError.

func (*ErrorWriter) WriteValue added in v0.15.0

func (vw *ErrorWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

func (*ErrorWriter) WriteVerboseError added in v0.21.1

func (vw *ErrorWriter) WriteVerboseError(st *State, err error)

WriteVerboseError writes the verbose error message of an error that implements VerboseError.

type FilterWriter added in v0.15.0

type FilterWriter[VW ValueWriter] struct {
	ValueWriter VW
	// Filter filters types.
	// The value is handled if it returns true or if it is nil.
	Filter func(typ reflect.Type) bool
}

FilterWriter is a ValueWriter that calls the ValueWriter if the filter returns true.

It should be created with NewFilterWriter.

func NewFilterWriter added in v0.15.0

func NewFilterWriter[VW ValueWriter](vw VW, f func(typ reflect.Type) bool) *FilterWriter[VW]

NewFilterWriter creates a new FilterWriter.

func (*FilterWriter[VW]) Supports added in v0.22.0

func (vw *FilterWriter[VW]) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*FilterWriter[VW]) WriteValue added in v0.15.0

func (vw *FilterWriter[VW]) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type FloatWriter added in v0.15.0

type FloatWriter struct {
	// Format is the format used to format the float.
	// Default: 'g'.
	Format byte
	// Precision is the precision used to format the float.
	// Default: -1.
	Precision int
}

FloatWriter is a ValueWriter that handles float values.

It should be created with NewFloatWriter.

func NewFloatWriter added in v0.15.0

func NewFloatWriter() *FloatWriter

NewFloatWriter creates a new FloatWriter with default values.

func (*FloatWriter) Supports added in v0.15.0

func (vw *FloatWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*FloatWriter) WriteValue added in v0.15.0

func (vw *FloatWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type FuncWriter added in v0.15.0

type FuncWriter struct {
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
}

FuncWriter is a ValueWriter that handles function values.

It should be created with NewFuncWriter.

func NewFuncWriter added in v0.15.0

func NewFuncWriter() *FuncWriter

NewFuncWriter creates a new FuncWriter with default values.

func (*FuncWriter) Supports added in v0.15.0

func (vw *FuncWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*FuncWriter) WriteValue added in v0.15.0

func (vw *FuncWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type GoStringerWriter added in v0.20.0

type GoStringerWriter struct{}

GoStringerWriter is a ValueWriter that handles fmt.GoStringer.

It should be created with NewGoStringerWriter.

func NewGoStringerWriter added in v0.20.0

func NewGoStringerWriter() *GoStringerWriter

NewGoStringerWriter creates a new GoStringerWriter.

func (*GoStringerWriter) Supports added in v0.20.0

func (vw *GoStringerWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*GoStringerWriter) WriteValue added in v0.20.0

func (vw *GoStringerWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type IntWriter added in v0.15.0

type IntWriter struct {
	// Base is the base used to format the integer.
	// Default: 10.
	Base int
}

IntWriter is a ValueWriter that handles int values.

It should be created with NewIntWriter.

func NewIntWriter added in v0.15.0

func NewIntWriter() *IntWriter

NewIntWriter creates a new IntWriter with default values.

func (*IntWriter) Supports added in v0.15.0

func (vw *IntWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*IntWriter) WriteValue added in v0.15.0

func (vw *IntWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type InterfaceWriter added in v0.15.0

type InterfaceWriter struct {
	ValueWriter
}

InterfaceWriter is a ValueWriter that handles interface values.

It should be created with NewInterfaceWriter.

func NewInterfaceWriter added in v0.15.0

func NewInterfaceWriter(vw ValueWriter) *InterfaceWriter

NewInterfaceWriter creates a new InterfaceWriter.

func (*InterfaceWriter) Supports added in v0.15.0

func (vw *InterfaceWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*InterfaceWriter) WriteValue added in v0.15.0

func (vw *InterfaceWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type InvalidWriter added in v0.15.0

type InvalidWriter struct{}

InvalidWriter is a ValueWriter that handles invalid values.

It should be created with NewInvalidWriter.

func NewInvalidWriter added in v0.15.0

func NewInvalidWriter() *InvalidWriter

NewInvalidWriter creates a new InvalidWriter.

func (*InvalidWriter) WriteValue added in v0.15.0

func (vw *InvalidWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type IterSeq2Writer added in v0.15.0

type IterSeq2Writer struct {
	ValueWriter
	// ShowKeysInfos shows keys infos.
	// Default: false.
	ShowKeysInfos bool
	// MaxLen is the maximum length of the iterator.
	// Default: 0 (no limit).
	MaxLen int
}

IterSeq2Writer is a ValueWriter that handles iter.Seq2.

It should be created with NewIterSeq2Writer.

func NewIterSeq2Writer added in v0.15.0

func NewIterSeq2Writer(vw ValueWriter) *IterSeq2Writer

NewIterSeq2Writer creates a new IterSeq2Writer with default values.

func (*IterSeq2Writer) Supports added in v0.15.0

func (vw *IterSeq2Writer) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*IterSeq2Writer) WriteValue added in v0.15.0

func (vw *IterSeq2Writer) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type IterSeqWriter added in v0.15.0

type IterSeqWriter struct {
	ValueWriter
	// MaxLen is the maximum length of the iterator.
	// Default: 0 (no limit).
	MaxLen int
}

IterSeqWriter is a ValueWriter that handles iter.Seq.

It should be created with NewIterSeqWriter.

func NewIterSeqWriter added in v0.15.0

func NewIterSeqWriter(vw ValueWriter) *IterSeqWriter

NewIterSeqWriter creates a new IterSeq2Writer with default values.

func (*IterSeqWriter) Supports added in v0.15.0

func (vw *IterSeqWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*IterSeqWriter) WriteValue added in v0.15.0

func (vw *IterSeqWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type IterWriter added in v0.18.6

type IterWriter struct {
	Seq  *IterSeqWriter
	Seq2 *IterSeq2Writer
}

IterWriter is a ValueWriter that handles iter.Seq and iter.Seq2.

It should be created with NewIterWriter.

func NewIterWriter added in v0.18.6

func NewIterWriter(vw ValueWriter) *IterWriter

NewIterWriter creates a new IterWriter with default values.

func (*IterWriter) Supports added in v0.18.6

func (vw *IterWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*IterWriter) WriteValue added in v0.18.6

func (vw *IterWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type KindWriter added in v0.15.0

type KindWriter struct {
	// The following fields are the default [ValueWriter] for each group of kinds.
	Invalid       *InvalidWriter
	Bool          *BoolWriter
	Int           *IntWriter
	Uint          *UintWriter
	Uintptr       *UintptrWriter
	Float         *FloatWriter
	Complex       *ComplexWriter
	Array         *ArrayWriter
	Chan          *ChanWriter
	Func          *FuncWriter
	Interface     *InterfaceWriter
	Map           *MapWriter
	Pointer       *PointerWriter
	Slice         *SliceWriter
	String        *StringWriter
	Struct        *StructWriter
	UnsafePointer *UnsafePointerWriter

	// ValueWriters is the list of [ValueWriter] indexed by [reflect.Kind].
	ValueWriters [kindsCount]ValueWriter
}

KindWriter is a ValueWriter that writes the value with the kind-specific ValueWriter.

It should be created with NewKindWriter.

func NewKindWriter added in v0.15.0

func NewKindWriter(vw ValueWriter) *KindWriter

NewKindWriter creates a new KindWriter with default values.

func (*KindWriter) Supports added in v0.15.0

func (vw *KindWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*KindWriter) WriteValue added in v0.15.0

func (vw *KindWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MapWriter added in v0.15.0

type MapWriter struct {
	ValueWriter
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// SortKeys sorts the keys.
	// Default: false.
	SortKeys bool
	// ShowKeysInfos shows keys infos.
	// Default: false.
	ShowKeysInfos bool
	// MaxLen is the maximum length of the map.
	// Default: 0 (no limit).
	MaxLen int
}

MapWriter is a ValueWriter that handles map values.

It should be created with NewMapWriter.

func NewMapWriter added in v0.15.0

func NewMapWriter(vw ValueWriter) *MapWriter

NewMapWriter creates a new MapWriter with default values.

func (*MapWriter) Supports added in v0.15.0

func (vw *MapWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*MapWriter) WriteValue added in v0.15.0

func (vw *MapWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MathBigFloatWriter added in v0.18.5

type MathBigFloatWriter struct {
	// Format is the format used to format the float.
	// Default: 'g'.
	Format byte
	// Precision is the precision used to format the float.
	// Default: -1.
	Precision int
}

MathBigFloatWriter is a ValueWriter that handles math/big.Float values.

It should be created with NewMathBigFloatWriter.

func NewMathBigFloatWriter added in v0.18.5

func NewMathBigFloatWriter() *MathBigFloatWriter

NewMathBigFloatWriter creates a new MathBigFloatWriter with default values.

func (*MathBigFloatWriter) Supports added in v0.18.5

func (vw *MathBigFloatWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*MathBigFloatWriter) WriteValue added in v0.18.5

func (vw *MathBigFloatWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MathBigIntWriter added in v0.13.0

type MathBigIntWriter struct {
	// Base is the base used to format the integer.
	// Default: 10.
	Base int
}

MathBigIntWriter is a ValueWriter that handles math/big.Int values.

It should be created with NewMathBigIntWriter.

func NewMathBigIntWriter added in v0.13.0

func NewMathBigIntWriter() *MathBigIntWriter

NewMathBigIntWriter creates a new MathBigIntWriter with default values.

func (*MathBigIntWriter) Supports added in v0.15.0

func (vw *MathBigIntWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*MathBigIntWriter) WriteValue added in v0.13.0

func (vw *MathBigIntWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MathBigRatWriter added in v0.18.5

type MathBigRatWriter struct{}

MathBigRatWriter is a ValueWriter that handles math/big.Rat values.

It should be created with NewMathBigRatWriter.

func NewMathBigRatWriter added in v0.18.5

func NewMathBigRatWriter() *MathBigRatWriter

NewMathBigRatWriter creates a new MathBigRatWriter with default values.

func (*MathBigRatWriter) Supports added in v0.18.5

func (vw *MathBigRatWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*MathBigRatWriter) WriteValue added in v0.18.5

func (vw *MathBigRatWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MathBigWriter added in v0.18.5

type MathBigWriter struct {
	Int   *MathBigIntWriter
	Float *MathBigFloatWriter
	Rat   *MathBigRatWriter
}

MathBigWriter is a ValueWriter thats handles values from the math/big package.

It should be created with NewMathBigWriter.

func NewMathBigWriter added in v0.18.5

func NewMathBigWriter() *MathBigWriter

NewMathBigWriter creates a new MathBigWriter with default values.

func (*MathBigWriter) Supports added in v0.18.5

func (vw *MathBigWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*MathBigWriter) WriteValue added in v0.18.5

func (vw *MathBigWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type MaxDepthWriter added in v0.15.0

type MaxDepthWriter struct {
	ValueWriter
	// Max is the maximum depth.
	// Default: 0 (no limit).
	Max int
}

MaxDepthWriter is a ValueWriter that limits the depth.

It should be created with NewMaxDepthWriter.

func NewMaxDepthWriter added in v0.15.0

func NewMaxDepthWriter(vw ValueWriter) *MaxDepthWriter

NewMaxDepthWriter creates a new MaxDepthWriter.

func (*MaxDepthWriter) WriteValue added in v0.15.0

func (vw *MaxDepthWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type PointerWriter added in v0.15.0

type PointerWriter struct {
	ValueWriter
	// ShowAddr shows the address.
	// Default: true.
	ShowAddr bool
}

PointerWriter is a ValueWriter that handles pointer values.

It should be created with NewPointerWriter.

func NewPointerWriter added in v0.15.0

func NewPointerWriter(vw ValueWriter) *PointerWriter

NewPointerWriter creates a new PointerWriter with default values.

func (*PointerWriter) Supports added in v0.15.0

func (vw *PointerWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*PointerWriter) WriteValue added in v0.15.0

func (vw *PointerWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type Printer added in v0.2.0

type Printer struct {
	// ValueWriter is the [ValueWriter] used to write values.
	ValueWriter ValueWriter
	// Indent is the string used to indent.
	// Default: "\t".
	Indent string
}

Printer pretty-prints values.

It should be created with NewPrinter.

func NewPrinter added in v0.2.0

func NewPrinter(vw ValueWriter) *Printer

NewPrinter creates a new Printer.

func (*Printer) Formatter added in v0.2.0

func (p *Printer) Formatter(vi any) fmt.Formatter

Formatter returns a fmt.Formatter for the value.

func (*Printer) String added in v0.2.0

func (p *Printer) String(vi any) string

String returns the value as a string.

func (*Printer) Write added in v0.2.0

func (p *Printer) Write(w io.Writer, vi any)

Write writes the value to the io.Writer.

It panics if there is a write error. For error handling, see Printer.WriteErr.

func (*Printer) WriteErr added in v0.15.0

func (p *Printer) WriteErr(w io.Writer, vi any) (err error)

WriteErr writes the value to the io.Writer and returns an error if it occurs.

type RangeWriter added in v0.17.0

type RangeWriter struct {
	ValueWriter
	// ShowKeysInfos shows keys infos.
	// Default: false.
	ShowKeysInfos bool
	// MaxLen is the maximum length of the iterator.
	// Default: 0 (no limit).
	MaxLen int
}

RangeWriter is a ValueWriter that handles values that implement the "Range" iter.Seq2 method such as sync.Map.

It should be created with NewRangeWriter.

func NewRangeWriter added in v0.17.0

func NewRangeWriter(vw ValueWriter) *RangeWriter

NewRangeWriter creates a new RangeWriter with the given IterSeq2Writer.

func (*RangeWriter) Supports added in v0.17.0

func (vw *RangeWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*RangeWriter) WriteValue added in v0.17.0

func (vw *RangeWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type RecursionWriter added in v0.15.0

type RecursionWriter struct {
	ValueWriter
	// ShowAddr shows the address (and type).
	// Default: true.
	ShowAddr bool
}

RecursionWriter is a ValueWriter that prevents recursion.

It should be created with NewRecursionWriter.

func NewRecursionWriter added in v0.15.0

func NewRecursionWriter(vw ValueWriter) *RecursionWriter

NewRecursionWriter creates a new RecursionWriter.

func (*RecursionWriter) WriteValue added in v0.15.0

func (vw *RecursionWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ReflectTypeWriter added in v0.12.0

type ReflectTypeWriter struct{}

ReflectTypeWriter is a ValueWriter that handles reflect.Type.

func NewReflectTypeWriter added in v0.12.0

func NewReflectTypeWriter() *ReflectTypeWriter

NewReflectTypeWriter returns a new ReflectTypeWriter.

func (*ReflectTypeWriter) Supports added in v0.15.0

func (vw *ReflectTypeWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ReflectTypeWriter) WriteValue added in v0.12.0

func (vw *ReflectTypeWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ReflectValueWriter added in v0.2.0

type ReflectValueWriter struct {
	ValueWriter
}

ReflectValueWriter is a ValueWriter that handles reflect.Value.

It should be created with NewReflectValueWriter.

func NewReflectValueWriter added in v0.2.0

func NewReflectValueWriter(vw ValueWriter) *ReflectValueWriter

NewReflectValueWriter creates a new ReflectValueWriter.

func (*ReflectValueWriter) Supports added in v0.15.0

func (vw *ReflectValueWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ReflectValueWriter) WriteValue added in v0.2.0

func (vw *ReflectValueWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ReflectWriter added in v0.18.6

type ReflectWriter struct {
	Value *ReflectValueWriter
	Type  *ReflectTypeWriter
}

ReflectWriter is a ValueWriter that handles reflect.Value and reflect.Type.

It should be created with NewReflectWriter.

func NewReflectWriter added in v0.18.6

func NewReflectWriter(vw ValueWriter) *ReflectWriter

NewReflectWriter creates a new ReflectWriter.

func (*ReflectWriter) Supports added in v0.18.6

func (vw *ReflectWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*ReflectWriter) WriteValue added in v0.18.6

func (vw *ReflectWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type SliceWriter added in v0.15.0

type SliceWriter struct {
	ValueWriter
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowCap shows the cap.
	// Default: true.
	ShowCap bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// ShowIndexes shows the indexes.
	// Default: false.
	ShowIndexes bool
	// MaxLen is the maximum length of the slice.
	// Default: 0 (no limit).
	MaxLen int
}

SliceWriter is a ValueWriter that handles slice values.

It should be created with NewSliceWriter.

func NewSliceWriter added in v0.15.0

func NewSliceWriter(vw ValueWriter) *SliceWriter

NewSliceWriter creates a new SliceWriter with default values.

func (*SliceWriter) Supports added in v0.15.0

func (vw *SliceWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*SliceWriter) WriteValue added in v0.15.0

func (vw *SliceWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type StackFramesError added in v0.19.0

type StackFramesError interface {
	StackFrames() []uintptr
}

StackFramesError is an interface that can be implemented by errors to provide stack frames.

type State

type State struct {
	Writer       io.Writer
	Depth        int
	IndentString string
	IndentLevel  int
	Visited      []VisitedEntry
	KnownType    bool
	ShowInfos    bool
}

State represents the state of the Printer.

Functions must restore the original state when they return.

func (*State) WriteIndent added in v0.9.0

func (st *State) WriteIndent()

WriteIndent writes the current indentation to the io.Writer.

type StringWriter added in v0.15.0

type StringWriter struct {
	// ShowLen shows the len.
	// Default: true.
	ShowLen bool
	// ShowAddr shows the address.
	// Default: false.
	ShowAddr bool
	// Quote quotes the string.
	// Default: true.
	Quote bool
	// MaxLen is the maximum length of the string.
	// Default: 0 (no limit).
	MaxLen int
}

StringWriter is a ValueWriter that handles string values.

It should be created with NewStringWriter.

func NewStringWriter added in v0.15.0

func NewStringWriter() *StringWriter

NewStringWriter creates a new StringWriter with default values.

func (*StringWriter) Supports added in v0.15.0

func (vw *StringWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*StringWriter) WriteValue added in v0.15.0

func (vw *StringWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type StringerWriter added in v0.15.0

type StringerWriter struct {
	// ShowLen shows the len.
	// Default: false.
	ShowLen bool
	// Quote quotes the string.
	// Default: true.
	Quote bool
	// MaxLen is the maximum length of the string.
	// Default: 0 (no limit).
	MaxLen int
}

StringerWriter is a ValueWriter that handles fmt.Stringer.

If fmt.Stringer.String panics, StringerWriter.WriteValue returns false.

It should be created with NewStringerWriter.

func NewStringerWriter added in v0.15.0

func NewStringerWriter() *StringerWriter

NewStringerWriter creates a new StringerWriter.

func (*StringerWriter) Supports added in v0.15.0

func (vw *StringerWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*StringerWriter) WriteValue added in v0.15.0

func (vw *StringerWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type StructFieldFilter added in v0.11.7

type StructFieldFilter func(v reflect.Value, field reflect.StructField) bool

StructFieldFilter is a function that filters struct fields.

It's used by StructWriter.

func NewExportedStructFieldFilter added in v0.11.7

func NewExportedStructFieldFilter() StructFieldFilter

NewExportedStructFieldFilter creates a new StructFieldFilter that returns true for exported fields and false otherwise.

type StructWriter added in v0.15.0

type StructWriter struct {
	ValueWriter
	// FieldFilter filters the fields.
	// Default: nil.
	FieldFilter StructFieldFilter
	// ShowFieldsType shows the type of the fields.
	// Default: true.
	ShowFieldsType bool
}

StructWriter is a ValueWriter that handles struct values.

It should be created with NewStructWriter.

func NewStructWriter added in v0.15.0

func NewStructWriter(vw ValueWriter) *StructWriter

NewStructWriter creates a new StructWriter with default values.

func (*StructWriter) Supports added in v0.15.0

func (vw *StructWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*StructWriter) WriteValue added in v0.15.0

func (vw *StructWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type SupportChecker added in v0.15.0

type SupportChecker interface {
	Supports(typ reflect.Type) ValueWriter
}

SupportChecker checks if a reflect.Type is supported. If the reflect.Type is supported, it returns a non nil ValueWriter.

type SupportCheckerFunc added in v0.15.0

type SupportCheckerFunc func(typ reflect.Type) ValueWriter

SupportCheckerFunc is a SupportChecker function.

func (SupportCheckerFunc) Supports added in v0.15.0

func (f SupportCheckerFunc) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

type SupportCheckerValueWriter added in v0.15.0

type SupportCheckerValueWriter struct {
	ValueWriter
	SupportChecker
}

SupportCheckerValueWriter implements ValueWriter and SupportChecker.

type SupportWriter added in v0.15.0

type SupportWriter struct {
	Checkers []SupportChecker
	// contains filtered or unexported fields
}

SupportWriter is a ValueWriter that selects a ValueWriter based on the reflect.Type of the reflect.Value. It selects the first SupportChecker that supports the reflect.Type.

It should be created with NewSupportWriter.

func NewSupportWriter added in v0.15.0

func NewSupportWriter() *SupportWriter

NewSupportWriter creates a new SupportWriter.

func (*SupportWriter) WriteValue added in v0.15.0

func (vw *SupportWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type TimeDurationWriter added in v0.21.2

type TimeDurationWriter struct{}

TimeDurationWriter is a ValueWriter that handles time.Duration values.

It should be created with NewTimeDurationWriter.

func NewTimeDurationWriter added in v0.21.2

func NewTimeDurationWriter() *TimeDurationWriter

NewTimeDurationWriter creates a new TimeDurationWriter.

func (*TimeDurationWriter) Supports added in v0.21.2

func (vw *TimeDurationWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*TimeDurationWriter) WriteValue added in v0.21.2

func (vw *TimeDurationWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type TimeLocationWriter added in v0.21.2

type TimeLocationWriter struct{}

TimeLocationWriter is a ValueWriter that handles time.Location values.

It should be created with NewTimeLocationWriter.

func NewTimeLocationWriter added in v0.21.2

func NewTimeLocationWriter() *TimeLocationWriter

NewTimeLocationWriter creates a new TimeLocationWriter.

func (*TimeLocationWriter) Supports added in v0.21.2

func (vw *TimeLocationWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*TimeLocationWriter) WriteValue added in v0.21.2

func (vw *TimeLocationWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type TimeTimeWriter added in v0.21.2

type TimeTimeWriter struct {
	// Format is the format of the time.
	// Default: [time.RFC3339Nano].
	Format string

	// Location to convert the time before formatting.
	// Default: nil (no conversion).
	Location *time.Location
}

TimeTimeWriter is a ValueWriter that handles time.Time values.

It should be created with NewTimeTimeWriter.

func NewTimeTimeWriter added in v0.21.2

func NewTimeTimeWriter() *TimeTimeWriter

NewTimeTimeWriter creates a new TimeTimeWriter with default values.

func (*TimeTimeWriter) Supports added in v0.21.2

func (vw *TimeTimeWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*TimeTimeWriter) WriteValue added in v0.21.2

func (vw *TimeTimeWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type TimeWriter added in v0.15.0

type TimeWriter struct {
	Time     *TimeTimeWriter
	Duration *TimeDurationWriter
	Location *TimeLocationWriter
}

TimeWriter is a ValueWriter that handles time.Time, time.Duration and time.Location.

It should be created with NewTimeWriter.

func NewTimeWriter added in v0.15.0

func NewTimeWriter() *TimeWriter

NewTimeWriter creates a new TimeWriter.

func (*TimeWriter) Supports added in v0.15.0

func (vw *TimeWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*TimeWriter) WriteValue added in v0.15.0

func (vw *TimeWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type TypeWriter added in v0.15.0

type TypeWriter struct {
	ValueWriter
	// ShowKnownTypes shows known types.
	// Default: false.
	ShowKnownTypes bool
	// ShowUnderlyingType shows the underlying type.
	// Default: true.
	ShowUnderlyingType bool
}

TypeWriter is a ValueWriter that writes the type of the value.

It should be created with NewTypeWriter.

func NewTypeWriter added in v0.15.0

func NewTypeWriter(vw ValueWriter) *TypeWriter

NewTypeWriter creates a new TypeWriter with default values.

func (*TypeWriter) WriteValue added in v0.15.0

func (vw *TypeWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type UintWriter added in v0.15.0

type UintWriter struct {
	// Base is the base used to format the integer.
	// Default: 10.
	Base int
}

UintWriter is a ValueWriter that handles uint values.

It should be created with NewUintWriter.

func NewUintWriter added in v0.15.0

func NewUintWriter() *UintWriter

NewUintWriter creates a new UintWriter with default values.

func (*UintWriter) Supports added in v0.15.0

func (vw *UintWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*UintWriter) WriteValue added in v0.15.0

func (vw *UintWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type UintptrWriter added in v0.15.0

type UintptrWriter struct{}

UintptrWriter is a ValueWriter that handles uintptr values.

It should be created with NewUintptrWriter.

func NewUintptrWriter added in v0.15.0

func NewUintptrWriter() *UintptrWriter

NewUintptrWriter creates a new UintptrWriter.

func (*UintptrWriter) Supports added in v0.15.0

func (vw *UintptrWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*UintptrWriter) WriteValue added in v0.15.0

func (vw *UintptrWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type UnsafePointerWriter added in v0.15.0

type UnsafePointerWriter struct{}

UnsafePointerWriter is a ValueWriter that handles unsafe pointer values.

It should be created with NewUnsafePointerWriter.

func NewUnsafePointerWriter added in v0.15.0

func NewUnsafePointerWriter() *UnsafePointerWriter

NewUnsafePointerWriter creates a new UnsafePointerWriter.

func (*UnsafePointerWriter) Supports added in v0.15.0

func (vw *UnsafePointerWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*UnsafePointerWriter) WriteValue added in v0.15.0

func (vw *UnsafePointerWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type UnwrapInterfaceWriter added in v0.15.0

type UnwrapInterfaceWriter struct {
	ValueWriter
}

UnwrapInterfaceWriter is a ValueWriter that unwraps interface values.

It should be created with NewUnwrapInterfaceWriter.

func NewUnwrapInterfaceWriter added in v0.15.0

func NewUnwrapInterfaceWriter(vw ValueWriter) *UnwrapInterfaceWriter

NewUnwrapInterfaceWriter creates a new UnwrapInterfaceWriter.

func (*UnwrapInterfaceWriter) WriteValue added in v0.15.0

func (vw *UnwrapInterfaceWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ValueWriter

type ValueWriter interface {
	WriteValue(st *State, v reflect.Value) bool
}

ValueWriter writes a reflect.Value to a io.Writer.

It returns true if it handles the value, false otherwise. If it returns false, it must not write anything.

Implementations must check reflect.Value.CanInterface before using reflect.Value.Interface.

Implentations can assume that the value is valid.

Example
vw := ValueWriterFunc(func(st *State, v reflect.Value) bool {
	_, _ = io.WriteString(st.Writer, "example")
	return true
})
p := NewPrinter(vw)
s := p.String("test")
fmt.Println(s)
Output:
example

type ValueWriterFunc added in v0.9.0

type ValueWriterFunc func(st *State, v reflect.Value) bool

ValueWriterFunc is a ValueWriter function.

func (ValueWriterFunc) WriteValue added in v0.9.0

func (f ValueWriterFunc) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type ValueWriters added in v0.2.0

type ValueWriters []ValueWriter

ValueWriters is a list of ValueWriter.

They are tried in order until one handles the value.

func (ValueWriters) Supports added in v0.15.0

func (vws ValueWriters) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (ValueWriters) WriteValue added in v0.2.0

func (vws ValueWriters) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

type VerboseError added in v0.18.0

type VerboseError interface {
	// ErrorVerbose writes the error verbose message.
	// It must only write the verbose message of the error, not the error chain.
	ErrorVerbose(w io.Writer)
}

VerboseError is an interface that can be implemented by errors to provide a verbose error message.

type VisitedEntry added in v0.15.0

type VisitedEntry struct {
	Type reflect.Type
	Addr uintptr
}

VisitedEntry represents a visited value.

type WeakPointerWriter added in v0.13.0

type WeakPointerWriter struct {
	ValueWriter
}

WeakPointerWriter is a ValueWriter that handles weak.Pointer.

It should be created with NewWeakPointerWriter.

func NewWeakPointerWriter added in v0.13.0

func NewWeakPointerWriter(vw ValueWriter) *WeakPointerWriter

NewWeakPointerWriter creates a new WeakPointerWriter with default values.

func (*WeakPointerWriter) Supports added in v0.15.0

func (vw *WeakPointerWriter) Supports(typ reflect.Type) ValueWriter

Supports implements SupportChecker.

func (*WeakPointerWriter) WriteValue added in v0.13.0

func (vw *WeakPointerWriter) WriteValue(st *State, v reflect.Value) bool

WriteValue implements ValueWriter.

Directories

Path Synopsis
ext
protobuf
Package protobuf provides a pretty.ValueWriter for protobuf messages.
Package protobuf provides a pretty.ValueWriter for protobuf messages.
internal
indent
Package indent provides utilities for writing indented output.
Package indent provides utilities for writing indented output.
itfassert
Package itfassert provides utilities to assert that a reflect.Value implements a specific interface type.
Package itfassert provides utilities to assert that a reflect.Value implements a specific interface type.
must
Package must provides helpers that panic.
Package must provides helpers that panic.
prettytest
Package prettytest provides utilities for testing the pretty package.
Package prettytest provides utilities for testing the pretty package.
write
Package write provides helpers to write.
Package write provides helpers to write.

Jump to

Keyboard shortcuts

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