Help us shape the future of Go! Take the 2026 Go Developer Survey

truncate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 4 Imported by: 200

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(b []byte, width uint) []byte

Bytes is shorthand for declaring a new default truncate-writer instance, used to immediately truncate a byte slice.

func BytesWithTail

func BytesWithTail(b []byte, width uint, tail []byte) []byte

Bytes is shorthand for declaring a new default truncate-writer instance, used to immediately truncate a byte slice. A tail is then added to the end of the byte slice.

func String

func String(s string, width uint) string

String is shorthand for declaring a new default truncate-writer instance, used to immediately truncate a string.

func StringWithTail

func StringWithTail(s string, width uint, tail string) string

StringWithTail is shorthand for declaring a new default truncate-writer instance, used to immediately truncate a string. A tail is then added to the end of the string.

Types

type Writer

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

func NewWriter

func NewWriter(width uint, tail string) *Writer

func NewWriterPipe

func NewWriterPipe(forward io.Writer, width uint, tail string) *Writer

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes returns the truncated result as a byte slice.

func (*Writer) String

func (w *Writer) String() string

String returns the truncated result as a string.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write truncates content at the given printable cell width, leaving any ansi sequences intact.

Jump to

Keyboard shortcuts

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