Documentation
¶
Overview ¶
Example (StringPointerBasic) ¶
Estos ejemplos ilustran cómo usar los punteros a strings para evitar asignaciones adicionales
// Creamos una variable string que queremos modificar myText := "héllô wórld" // En lugar de crear una nueva variable con el resultado, // modificamos directamente la variable original usando Apply() Convert(&myText).RemoveTilde().ToLower().Apply() // La variable original ha sido modificada fmt.Println(myText)
Output: hello world
Example (StringPointerCamelCase) ¶
// Ejemplo de uso con múltiples transformaciones originalText := "Él Múrcielago Rápido" // Las transformaciones modifican la variable original directamente // usando el método Apply() para actualizar el puntero Convert(&originalText).RemoveTilde().CamelCaseLower().Apply() fmt.Println(originalText)
Output: elMurcielagoRapido
Example (StringPointerEfficiency) ¶
// En aplicaciones de alto rendimiento, reducir asignaciones de memoria // puede ser importante para evitar la presión sobre el garbage collector // Método tradicional (crea nuevas asignaciones de memoria) traditionalText := "Texto con ACENTOS" processedText := Convert(traditionalText).RemoveTilde().ToLower().String() fmt.Println(processedText) // Método con punteros (modifica directamente la variable original) directText := "Otro TEXTO con ACENTOS" Convert(&directText).RemoveTilde().ToLower().Apply() fmt.Println(directText)
Output: texto con acentos otro texto con acentos
Index ¶
- Constants
- Variables
- func Contains(conv, search string) bool
- func Convert(v ...any) *conv
- func CountOccurrences(conv, search string) int
- func Err(values ...any) *conv
- func Errf(format string, args ...any) *conv
- func Fmt(format string, args ...any) *conv
- func OutLang(l ...lang)
- func ParseKeyValue(in string, delimiters ...string) (value string, err error)
- func Split(data string, separator ...string) (result []string)
- func T(values ...any) string
- type OL
Examples ¶
Constants ¶
const ( EN lang = iota // 0 - English (default) ES // 1 - Spanish PT // 2 - Portuguese FR // 3 - French RU // 4 - Russian DE // 5 - German IT // 6 - Italian HI // 7 - Hindi BN // 8 - Bengali ID // 9 - Indonesian AR // 10 - Arabic UR // 11 - Urdu ZH // 12 - Chinese )
Variables ¶
var D = dictionary{ Argument: OL{"argument", "argumento", "argumento", "argument", "аргумент", "Argument", "argomento", "तर्क", "যুক্তি", "argumen", "وسيط", "دلیل", "参数"}, At: OL{"at", "en", "em", "à", "в", "bei", "a", "पर", "এ", "di", "في", "میں", "在"}, Base: OL{"base", "base", "base", "base", "основание", "Basis", "base", "आधार", "ভিত্তি", "basis", "قاعدة", "بنیاد", "进制"}, Boolean: OL{"boolean", "booleano", "booleano", "booléen", "логический", "boolescher", "booleano", "बूलियन", "বুলিয়ান", "boolean", "منطقي", "بولین", "布尔"}, Cannot: OL{"cannot", "no puede", "não pode", "ne peut pas", "не может", "kann nicht", "non può", "नहीं कर सकते", "পারে না", "tidak bisa", "لا يمكن", "نہیں کر سکتے", "不能"}, Empty: OL{"empty", "vacío", "vazio", "vide", "пустой", "leer", "vuoto", "खाली", "খালি", "kosong", "فارغ", "خالی", "空"}, End: OL{"end", "fin", "fim", "fin", "конец", "Ende", "fine", "अंत", "শেষ", "akhir", "نهاية", "اختتام", "结束"}, Float: OL{"float", "flotante", "flutuante", "flottant", "число с плавающей точкой", "Gleitkomma", "virgola mobile", "फ्लोट", "ফ্লোট", "float", "عائم", "فلوٹ", "浮点"}, For: OL{"for", "para", "para", "pour", "для", "für", "per", "के लिए", "জন্য", "untuk", "لـ", "کے لیے", "为"}, Fmt: OL{"format", "formato", "formato", "format", "формат", "Fmt", "formato", "प्रारूप", "বিন্যাস", "format", "تنسيق", "فارمیٹ", "格式"}, Found: OL{"found", "encontrado", "encontrado", "trouvé", "найден", "gefunden", "trovato", "मिला", "পাওয়া", "ditemukan", "موجود", "ملا", "找到"}, Integer: OL{"integer", "entero", "inteiro", "entier", "целое число", "ganze Zahl", "intero", "पूर्णांक", "পূর্ণসংখ্যা", "integer", "عدد صحيح", "انٹیجر", "整数"}, Invalid: OL{"invalid", "inválido", "inválido", "invalide", "недопустимый", "ungültig", "non valido", "अमान्य", "অবৈধ", "tidak valid", "غير صالح", "غیر درست", "无效"}, Missing: OL{"missing", "falta", "ausente", "manquant", "отсутствует", "fehlend", "mancante", "गुम", "অনুপস্থিত", "hilang", "مفقود", "غائب", "缺少"}, Negative: OL{"negative", "negativo", "negativo", "négatif", "отрицательный", "negativ", "negativo", "नकारात्मक", "নেগেটিভ", "negatif", "سالب", "منفی", "负"}, NegativeUnsigned: OL{"negative numbers are not supported for unsigned integers", "números negativos no soportados para enteros sin signo", "números negativos não suportados para inteiros sem sinal", "nombres négatifs non pris en charge pour les entiers non signés", "отрицательные числа не поддерживаются для беззнаковых целых чисел", "negative Zahlen werden für vorzeichenlose Ganzzahlen nicht unterstützt", "numeri negativi non supportati per interi senza segno", "नकारात्मक संख्याएं अहस्ताक्षरित पूर्णांकों के लिए समर्थित नहीं हैं", "স্বাক্ষরহীন পূর্ণসংখ্যার জন্য নেগেটিভ সংখ্যা সমর্থিত নয়", "angka negatif tidak didukung untuk integer tanpa tanda", "الأرقام السالبة غير مدعومة للأعداد الصحيحة غير الموقعة", "منفی نمبرز غیر دستخط انٹیجرز کے لیے معاون نہیں", "无符号整数不支持负数"}, NonNumeric: OL{"non-numeric", "no numérico", "não numérico", "non numérique", "нечисловой", "nicht numerisch", "non numerico", "गैर-संख्यात्मक", "অ-সংখ্যাসূচক", "non-numerik", "غير رقمي", "غیر عددی", "非数字"}, Not: OL{"not", "no", "não", "pas", "не", "nicht", "non", "नहीं", "না", "tidak", "ليس", "نہیں", "不"}, Number: OL{"number", "número", "número", "nombre", "число", "Zahl", "numero", "संख्या", "সংখ্যা", "angka", "رقم", "نمبر", "数字"}, Numbers: OL{"numbers", "números", "números", "nombres", "числа", "Zahlen", "numeri", "संख्याएं", "সংখ্যা", "angka", "أرقام", "نمبرز", "数字"}, Of: OL{"of", "de", "de", "de", "из", "von", "di", "का", "এর", "dari", "من", "کا", "的"}, One: OL{"one", "uno", "um", "un", "один", "eins", "uno", "एक", "একটি", "satu", "واحد", "ایک", "一"}, Only: OL{"only", "solo", "apenas", "seulement", "только", "nur", "solo", "केवल", "শুধুমাত্র", "hanya", "فقط", "صرف", "仅"}, Overflow: OL{"overflow", "desbordamiento", "estouro", "débordement", "переполнение", "Überlauf", "overflow", "ओवरफ्लो", "ওভারফ্লো", "overflow", "فيض", "اوور فلو", "溢出"}, Range: OL{"range", "rango", "intervalo", "plage", "диапазон", "Bereich", "intervallo", "रेंज", "পরিসর", "rentang", "نطاق", "رینج", "范围"}, Required: OL{"required", "requerido", "necessário", "requis", "обязательный", "erforderlich", "richiesto", "आवश्यक", "প্রয়োজনীয়", "diperlukan", "مطلوب", "ضروری", "必需"}, Round: OL{"round", "redondear", "arredondar", "arrondir", "округлить", "runden", "arrotondare", "गोल", "গোল", "bulatkan", "جولة", "گول", "圆"}, Specifier: OL{"specifier", "especificador", "especificador", "spécificateur", "спецификатор", "Spezifizierer", "specificatore", "निर्दिष्टकर्ता", "নির্দিষ্টকারী", "penentu", "محدد", "تعین کنندہ", "说明符"}, String: OL{"string", "cadena", "string", "chaîne", "строка", "Zeichenkette", "stringa", "स्ट्रिंग", "স্ট্রিং", "string", "سلسلة", "سٹرنگ", "字符串"}, Supported: OL{"supported", "soportado", "suportado", "pris en charge", "поддерживается", "unterstützt", "supportato", "समर्थित", "সমর্থিত", "didukung", "مدعوم", "معاون", "支持"}, Text: OL{"text", "texto", "texto", "texte", "текст", "Text", "testo", "पाठ", "পাঠ", "teks", "نص", "متن", "文本"}, Type: OL{"type", "tipo", "tipo", "type", "тип", "Typ", "tipo", "प्रकार", "টাইপ", "tipe", "نوع", "قسم", "类型"}, Unknown: OL{"unknown", "desconocido", "desconhecido", "inconnu", "неизвестный", "unbekannt", "sconosciuto", "अज्ञात", "অজানা", "tidak diketahui", "غير معروف", "نامعلوم", "未知"}, Unsigned: OL{"unsigned", "sin signo", "sem sinal", "non signé", "беззнаковый", "vorzeichenlos", "senza segno", "अहस्ताक्षरित", "স্বাক্ষরহীন", "tidak bertanda", "غير موقع", "غیر دستخط شدہ", "无符号"}, Unsupported: OL{"unsupported", "no soportado", "não suportado", "non pris en charge", "не поддерживается", "nicht unterstützt", "non supportato", "असमर्थित", "অসমর্থিত", "tidak didukung", "غير مدعوم", "غیر معاون", "不支持"}, Value: OL{"value", "valor", "valor", "valeur", "значение", "Wert", "valore", "मूल्य", "মান", "nilai", "قيمة", "قیمت", "值"}, Wrong: OL{"wrong", "incorrecto", "errado", "mauvais", "неправильный", "falsch", "sbagliato", "गलत", "ভুল", "salah", "خطأ", "غلط", "错误"}, }
Global dictionary instance - populated with all translations using horizontal format
Functions ¶
func Contains ¶ added in v0.0.8
Contains checks if the string 'search' is present in 'conv' Returns true if found, false otherwise This matches the behavior of the standard library strings.Contains
func Convert ¶
func Convert(v ...any) *conv
Convert initializes a new conv struct with optional value for string,bool and number manipulation. REFACTORED: Now accepts variadic parameters - Convert() or Convert(value) Phase 7: Uses object pool internally for memory optimization (transparent to user)
func CountOccurrences ¶ added in v0.0.8
CountOccurrences checks how many times the string 'search' is present in 'conv' eg: "hello world" with search "world" will return 1
func Err ¶ added in v0.0.37
func Err(values ...any) *conv
Err creates a new error message with support for multilingual translations REFACTORED: Uses T function and pool for optimal performance Supports OL types for translations and lang types for language specification Maintains backward compatibility with existing string-based errors eg: tinystring.Err("invalid format") returns "invalid format" tinystring.Err(D.Invalid, D.Fmt) returns "invalid format" tinystring.Err(ES,D.Fmt, D.Invalid) returns "formato inválido"
func Errf ¶ added in v0.1.3
Errf creates a new conv instance with error formatting similar to fmt.Errf Example: tinystring.Errf("invalid value: %s", value).Error()
func Fmt ¶ added in v0.1.3
Fmt creates a new conv instance with variadic formatting similar to fmt.Sprintf Example: tinystring.Fmt("Hello %s, you have %d messages", "Alice", 5).String() with error: out, err := tinystring.Fmt("Hello %s, you have %d messages", "Alice", 5).StringError()
func OutLang ¶ added in v0.1.3
func OutLang(l ...lang)
OutLang sets the default output language OutLang() without parameters auto-detects system language OutLang(ES) sets Spanish as default
func ParseKeyValue ¶ added in v0.0.10
ParseKeyValue extracts the value part from a "key:value" formatted string. By default, it uses ":" as the delimiter but accepts an optional custom delimiter. The function returns the value part and an error (nil if successful).
Examples:
value, err := ParseKeyValue("name:John")
// value = "John", err = nil
value, err := ParseKeyValue("data=123", "=")
// value = "123", err = nil
value, err := ParseKeyValue("invalid-string")
// value = "", err = error containing "delimiter ':' not found in string invalid-string"
func T ¶ added in v0.1.3
T creates a translated string with support for multilingual translations Same functionality as Err but returns string directly instead of *conv This function is used internally by the builder API for efficient string construction
Usage examples: T(D.Invalid, D.Format) returns "invalid format" T(ES, D.Invalid, D.Format) returns "formato inválido"