text

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 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 text provides string, line, and edit-distance text manipulation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLineFromOffset

func GetLineFromOffset(content string, offset int) int

GetLineFromOffset returns the 1-based line number for a given byte offset in content.

func GetLineOffsets

func GetLineOffsets(content string, startLine, endLine int) (int, int, error)

GetLineOffsets returns the start and end byte offsets for the given 1-based line range in content.

func GetSnippet

func GetSnippet(content string, lineNum int) string

GetSnippet returns a snippet centered around lineNum in content.

func IsWhitespace

func IsWhitespace(r rune) bool

IsWhitespace reports whether a rune is a standard space, tab, newline, or unicode whitespace character.

func Levenshtein

func Levenshtein(s1, s2 string) int

Levenshtein computes the Levenshtein edit distance between two strings. It operates on runes to correctly handle multi-byte characters.

func Normalize

func Normalize(s string) string

Normalize strips all whitespace characters from a string.

func Similarity

func Similarity(s1, s2 string) float64

Similarity calculates the normalized similarity score (0.0 to 1.0) between two strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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