text

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package text holds the small string-shortening helpers that were copied, subtly differently, into half a dozen packages. They share one rule that is load-bearing here: a truncation must land on a rune boundary. Several of these strings end up in a vault markdown file, and a byte slice through a multibyte rune writes invalid UTF-8 into truth (invariant 1).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ellipsize

func Ellipsize(s string, n int) string

Ellipsize shortens s to at most n runes, appending "…" when it had to cut so the reader can see the value is not complete (invariant 3). The "…" counts toward n, so the result is never wider than n runes.

func Truncate

func Truncate(s string, n int) string

Truncate shortens s to at most n runes with no marker. It is for values whose tail is noise rather than information — a UUID prefix, a commit hash, the fixed-width timestamp at the head of a checkpoint filename — where an "…" would be worse than the silent cut.

Types

This section is empty.

Jump to

Keyboard shortcuts

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