Break utils package into subpackages.
This commit is contained in:
parent
06ecd73f67
commit
d7a5adb239
25 changed files with 276 additions and 318 deletions
24
internal/utils/dbidentifier/dbidentifier.go
Normal file
24
internal/utils/dbidentifier/dbidentifier.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package dbidentifier
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/v2/internal/3rdparty/snaker"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ToGoIdentifier converts database identifier to Go identifier.
|
||||
func ToGoIdentifier(databaseIdentifier string) string {
|
||||
return snaker.SnakeToCamel(replaceInvalidChars(databaseIdentifier))
|
||||
}
|
||||
|
||||
// ToGoFileName converts database identifier to Go file name.
|
||||
func ToGoFileName(databaseIdentifier string) string {
|
||||
return strings.ToLower(replaceInvalidChars(databaseIdentifier))
|
||||
}
|
||||
|
||||
func replaceInvalidChars(str string) string {
|
||||
str = strings.Replace(str, " ", "_", -1)
|
||||
str = strings.Replace(str, "-", "_", -1)
|
||||
str = strings.Replace(str, ".", "_", -1)
|
||||
|
||||
return str
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue