Files
gdulai ffd9cd004e
Go Tests / test (push) Failing after 6s
Introduce Exec interface and implementers (#1)
Reviewed-on: #1
2026-05-11 06:03:40 +00:00

22 lines
407 B
Go

package util
import (
"strings"
"unicode"
)
func CamelToSnake(str string) string {
var snake strings.Builder
isPrevUpper := true
for _, c := range str {
if unicode.IsUpper(c) && !isPrevUpper {
snake.WriteString("_" + string(unicode.ToUpper(c)))
isPrevUpper = true
} else {
snake.WriteString(string(unicode.ToUpper(c)))
isPrevUpper = unicode.IsUpper(c)
}
}
return snake.String()
}