thanks ChatGPT
(s string)
| 100 | |
| 101 | // thanks ChatGPT |
| 102 | func snakeToPascal(s string) string { |
| 103 | // Split the input string into words. |
| 104 | words := strings.Split(s, "_") |
| 105 | |
| 106 | // Convert the first letter of each word to uppercase and concatenate them. |
| 107 | var builder strings.Builder |
| 108 | for _, w := range words { |
| 109 | if len(w) > 0 { |
| 110 | builder.WriteString(strings.ToUpper(w[:1])) |
| 111 | builder.WriteString(w[1:]) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | return builder.String() |
| 116 | } |
no test coverage detected