textutil

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 2 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 textutil holds small string helpers shared across packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clip

func Clip(s string, max int) (string, bool)

Clip truncates s to at most max bytes without splitting a multibyte UTF-8 rune, returning the (possibly shorter) string and whether it was truncated. Backing off to a rune boundary avoids feeding the model — and the JSONL trace — a broken trailing rune (the byte-cap-halves-Cyrillic bug class).

func OneLine added in v0.17.0

func OneLine(s string, max int) string

OneLine collapses all runs of whitespace (incl. newlines) to single spaces and rune-safely clips the result to at most max bytes — the shared "flatten to one tidy line, capped" helper used across the packages for log/error rendering.

func Tail added in v0.23.0

func Tail(s string, max int) string

Tail keeps the last max bytes of s, backing off to a rune boundary so a multibyte character is never split; a clipped result is prefixed with "…". The counterpart of Clip for when the END of the text is the valuable part (e.g. a CLI agent's final answer after pages of progress noise).

Types

This section is empty.

Jump to

Keyboard shortcuts

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