strutil

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 1 Imported by: 0

README

StrUtil Package (internal/strutil)

High-performance string utilities.

Overview

This package provides optimized string manipulation functions used throughout HotPlex, particularly in security-critical paths like regex scanning.

Usage

import "github.com/hrygo/hotplex/internal/strutil"

// Truncate string with ellipsis
short := strutil.Truncate("very long string...", 10)
// Result: "very lo..."

// Safe substring (handles Unicode)
sub := strutil.SafeSubstring("Hello 世界", 0, 8)

Design Goals

  • Zero Allocation: Critical paths minimize garbage collection
  • Unicode Safe: Proper handling of multi-byte characters
  • Security Focused: Used in WAF pattern matching

Files

File Purpose
strutil.go String utility functions

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Truncate

func Truncate(s string, maxLen int) string

Truncate strings at rune level to avoid invalid UTF-8. If maxLen < 4, returns a raw byte slice without appending "..." to avoid panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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