Add getCasdoorColumns().

This commit is contained in:
Yang Luo
2021-12-20 00:26:46 +08:00
parent db56f54b8c
commit e64f181e28
5 changed files with 57 additions and 25 deletions

View File

@ -15,6 +15,7 @@
package util
import (
"bytes"
"crypto/md5"
"encoding/hex"
"errors"
@ -52,6 +53,22 @@ func BoolToString(b bool) string {
}
}
func CamelToSnakeCase(camel string) string {
var buf bytes.Buffer
for _, c := range camel {
if 'A' <= c && c <= 'Z' {
// just convert [A-Z] to _[a-z]
if buf.Len() > 0 {
buf.WriteRune('_')
}
buf.WriteRune(c - 'A' + 'a')
} else {
buf.WriteRune(c)
}
}
return buf.String()
}
func GetOwnerAndNameFromId(id string) (string, string) {
tokens := strings.Split(id, "/")
if len(tokens) != 2 {