textutil

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package textutil holds small string helpers shared across packages.

The truncation helpers exist because ad-hoc byte slicing (s[:n]) can split a multibyte UTF-8 rune, producing invalid UTF-8 in transcripts, tool results, and terminal output. Use these instead of slicing by byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClipBytes

func ClipBytes(s string, max int) string

ClipBytes returns s truncated to at most max bytes without splitting a UTF-8 rune: the cut backs up to the nearest rune boundary. Use when the budget is genuinely in bytes (wire limits, log caps).

func ClipRunes

func ClipRunes(s string, max int) string

ClipRunes returns s truncated to at most max runes.

func ClipRunesEllipsis

func ClipRunesEllipsis(s string, max int) string

ClipRunesEllipsis returns s truncated to at most max runes, appending an ellipsis when truncation occurred.

Types

This section is empty.

Jump to

Keyboard shortcuts

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