Junior
Como determinar o número de caracteres numa string?
sobes.tech IA
Resposta da IA
Используя функцию utf8.RuneCountInString() из пакета unicode/utf8.
import (
"fmt"
"unicode/utf8"
)
func main() {
str := "Привет, мир!"
count := utf8.RuneCountInString(str) // Подсчитывает количество рун (символов)
fmt.Println(count) // Вывод: 12
}