id作为关键字符转为全大写ID, 而不是Id

This commit is contained in:
白茶清欢 2021-11-17 11:41:50 +08:00
parent 4652955c2a
commit c97a3b3bcb

View File

@ -71,6 +71,11 @@ func SnakeCaseToCamel(str string) string {
continue
}
}
// 将ID转为大写
if str[i] == 'd' && i-1 >= 0 && (str[i-1] == 'i' || str[i-1] == 'I') && (i+1 == len(str) || i+1 < len(str) && str[i+1] == '_') {
builder.WriteByte('d' - ('a' - 'A'))
continue
}
builder.WriteByte(str[i])
}
return builder.String()