From 8b0b6a318c7d5b44b8db34626733abf218873535 Mon Sep 17 00:00:00 2001 From: SirSova <fly.shadow373@gmail.com> Date: Tue, 26 Sep 2023 13:50:00 +0300 Subject: [PATCH] return back "strcase" functions for InterfaceName add deprecation comment --- go.mod | 1 + go.sum | 2 ++ go.work.sum | 2 +- pkg/outputter.go | 15 +++++++++------ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 42c15b78..0a52d015 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/chigopher/pathlib v0.15.0 github.com/davecgh/go-spew v1.1.1 github.com/huandu/xstrings v1.4.0 + github.com/iancoleman/strcase v0.2.0 github.com/jinzhu/copier v0.3.5 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.5.0 diff --git a/go.sum b/go.sum index 0a72f05c..e6962530 100644 --- a/go.sum +++ b/go.sum @@ -130,6 +130,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= diff --git a/go.work.sum b/go.work.sum index 1f74b819..2a9b8253 100644 --- a/go.work.sum +++ b/go.work.sum @@ -443,7 +443,7 @@ github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= -github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= diff --git a/pkg/outputter.go b/pkg/outputter.go index 70c31223..2f1a8192 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -15,6 +15,7 @@ import ( "github.com/chigopher/pathlib" "github.com/huandu/xstrings" + "github.com/iancoleman/strcase" "github.com/rs/zerolog" "github.com/vektra/mockery/v2/pkg/config" @@ -219,12 +220,14 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac PackageName string PackagePath string }{ - InterfaceDir: filepath.Dir(iface.FileName), - InterfaceDirRelative: interfaceDirRelative, - InterfaceName: iface.Name, - InterfaceNameCamel: xstrings.ToCamelCase(iface.Name), - InterfaceNameLowerCamel: xstrings.FirstRuneToLower(xstrings.ToCamelCase(iface.Name)), - InterfaceNameSnake: xstrings.ToSnakeCase(iface.Name), + InterfaceDir: filepath.Dir(iface.FileName), + InterfaceDirRelative: interfaceDirRelative, + InterfaceName: iface.Name, + // Deprecated: All custom case variables of InterfaceName will be removed in the next major version + // Use the template functions instead + InterfaceNameCamel: strcase.ToCamel(iface.Name), + InterfaceNameLowerCamel: strcase.ToLowerCamel(iface.Name), + InterfaceNameSnake: strcase.ToSnake(iface.Name), InterfaceNameLower: strings.ToLower(iface.Name), Mock: mock, MockName: c.MockName,