From f34c5e7fe830962be0337aed7a5c54df32ced27e Mon Sep 17 00:00:00 2001 From: go-jet Date: Thu, 4 Jul 2019 14:42:50 +0200 Subject: [PATCH] Build fix. --- .circleci/config.yml | 3 +-- internal/util/utils.go | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) 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 }