truncate

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package truncate shortens long values before they are logged or printed, marking where they were cut.

Index

Constants

View Source
const MaxLogLength = 200

MaxLogLength is the maximum length for log output to prevent log bloat

Variables

This section is empty.

Functions

func Message

func Message() string

Message returns the colored marker appended to a truncated value.

func String

func String(s string, maxLen int) string

String cuts s to at most maxLen bytes and appends Message when s is longer. The cut backs off to the start of a rune, so a multibyte character, such as one of Japanese text, is never split in two. It backs off no further than a rune can be long: past that the bytes are not UTF-8, and they are cut where maxLen falls rather than all left out.

func Value

func Value(v any, maxLen int) any

Value truncates the long strings in v, a value an action logs, at any depth, keeping its maps and lists as they are laid out, so that what logs it shows them as such. A map comes back as a map[string]any and a list as a []any, other than a []byte, which is left as it is, as are numbers and booleans. Any other value, such as a struct, is turned into a string and truncated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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