TinyString is a lightweight Go library that provides comprehensive string manipulation, type conversion, formatting, and multilingual error handling with a fluid API, specifically designed for small devices and web applications using TinyGo as the target compiler.
- 🚀 Fluid and chainable API - Easy to use and readable operations
- 📝 Complete string toolkit - Transformations, conversions, formatting, and error handling
- 🌍 Multilingual error messages - Built-in dictionary system with 9 languages
- 🧵 Concurrency safe - Thread-safe operations for concurrent environments
- 📦 Zero dependencies - No
fmt,strings,strconv, orerrorsimports - 🎯 TinyGo optimized - Manual implementations for minimal binary size
- 🌐 WebAssembly-first - Designed for modern web deployment
- 🔄 Universal type support - Works with strings, numbers, booleans, and slices
- ⚡ Performance focused - Predictable allocations and custom optimizations
go get github.com/cdvelop/tinystringimport . "github.com/cdvelop/tinystring"
// Quick start - Basic conversion and transformation
text := Convert("Hóla Múndo").Tilde().ToLower().String() // out: "hola mundo"
// Working with different data types
numText := Convert(42).String() // out: "42"
boolText := Convert(true).String() // out: "true"
// Memory-efficient approach using string pointers
original := "Él Múrcielago Rápido"
Convert(&original).Tilde().CamelLow().Apply()
// original is now: "elMurcielagoRapido"
// Efficient builder and chaining with accent normalization
items := []string{" ÁPPLE ", " banána ", " piñata "," ÑANDÚ "}
builder := Convert() // without params reused buffer = optimal performance
for i, item := range items {
processed := Convert(item).
TrimSpace(). // TrimSpace whitespace
Tilde(). // Normalize accents
ToLower(). // Convert to lowercase
Capitalize(). // Capitalize first letter
String() // Finalize the string
builder.Write(processed)
if i < len(items)-1 {
builder.Write(" - ")
}
}
out := builder.String() // Finalize the string hiding the error
out, err := builder.StringErr() // OR finalize with error handling
// out: "Apple - Banana - Piñata - Ñandu", err: nil- Errors Package Equivalents - Replace errors package functions
- Filepath Package Equivalents - Replace filepath package functions
- Fmt Package Equivalents - Replace fmt package functions
- HTML Escaping - HTML attribute and content escaping
- ID and Primary Key Detection - Field naming conventions
- Key-Value Parsing - Parse key-value strings
- Message Types - Message classification system
- Smart Truncation - Text truncation utilities
- Strings Package Equivalents - Replace strings package functions
- Strconv Package Equivalents - Replace strconv package functions
- Struct Tag Extraction - Extract values from struct tags
- Translation Guide - Multilingual error messages