textutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 3 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 added in v0.2.1

func Clip(text string, maxRunes int, mark string) string

Clip cuts text to at most maxRunes runes, mark included, ending the cut with mark ("…", "..." or a notice); maxRunes <= 0 keeps text whole.

func ClipBytes added in v0.2.1

func ClipBytes(text string, maxBytes int) string

ClipBytes cuts text to at most maxBytes bytes on a rune boundary, for limits counted in bytes (a websocket close reason).

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

FirstNonEmpty returns the first value that is not blank, trimmed. Use cmp.Or instead when the values are already trimmed.

func NonBlank

func NonBlank(values ...string) []string

NonBlank returns the values trimmed, without the blank ones.

func UniqueNonBlank

func UniqueNonBlank(values ...string) []string

UniqueNonBlank is NonBlank without repeats; the first occurrence stays.

Types

This section is empty.

Jump to

Keyboard shortcuts

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