diff --git a/.circleci/config.yml b/.circleci/config.yml index cc6b208..c040498 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,10 +28,9 @@ jobs: command: | go get github.com/google/uuid go get github.com/lib/pq + go get github.com/pkg/profile go get gotest.tools/assert - go get github.com/onsi/ginkgo - go get github.com/onsi/gomega go get github.com/davecgh/go-spew/spew go get github.com/jstemmer/go-junit-report diff --git a/internal/util/utils.go b/internal/util/utils.go index cb9f989..e0e1830 100644 --- a/internal/util/utils.go +++ b/internal/util/utils.go @@ -9,15 +9,17 @@ func ToGoIdentifier(databaseIdentifier string) string { if len(databaseIdentifier) == 0 { return databaseIdentifier } - databaseIdentifier = strings.ReplaceAll(databaseIdentifier, " ", "_") - databaseIdentifier = strings.ReplaceAll(databaseIdentifier, "-", "_") - return snaker.SnakeToCamel(databaseIdentifier) + return snaker.SnakeToCamel(replaceInvalidChars(databaseIdentifier)) } func ToGoFileName(databaseIdentifier string) string { - databaseIdentifier = strings.ReplaceAll(databaseIdentifier, " ", "_") - databaseIdentifier = strings.ReplaceAll(databaseIdentifier, "-", "_") - - return strings.ToLower(databaseIdentifier) + return strings.ToLower(replaceInvalidChars(databaseIdentifier)) +} + +func replaceInvalidChars(str string) string { + str = strings.Replace(str, " ", "_", -1) + str = strings.Replace(str, "-", "_", -1) + + return str }