From b0f2914019ea9bdf503ffa8cb79812a40310abcd Mon Sep 17 00:00:00 2001 From: George Suntres Date: Wed, 1 Apr 2026 23:03:55 -0400 Subject: [PATCH] Use commons for case changes --- go.mod | 9 +++++---- go.sum | 10 ++++++++++ persist.go | 6 +----- persist_deleteone.go | 3 ++- persist_find.go | 3 ++- persist_findone.go | 3 ++- persist_getone.go | 3 ++- persist_insertone.go | 3 ++- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index cfa55c0..e7a72e9 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module git.gsuntres.com/general/persist go 1.25.0 require ( - git.gsuntres.com/general/commons v0.0.0-20260329171253-65eec3c3b1e3 + git.gsuntres.com/general/commons v0.0.0-20260402010100-7e8cf14bb0a5 git.gsuntres.com/general/mongo v0.0.0-20260329164619-eff6c4ecee15 - git.gsuntres.com/general/structful v0.0.0-20260330181942-47f7fdf9c083 + git.gsuntres.com/general/structful v0.0.0-20260402004702-c83e44b04a9f github.com/go-viper/mapstructure/v2 v2.5.0 github.com/testcontainers/testcontainers-go v0.41.0 github.com/testcontainers/testcontainers-go/modules/mongodb v0.41.0 @@ -16,7 +16,7 @@ require ( require ( dario.cat/mergo v1.0.2 // indirect - git.gsuntres.com/general/sys v0.0.0-20260329160429-49966ca31027 // indirect + git.gsuntres.com/general/sys v0.0.1 // indirect github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect @@ -39,7 +39,7 @@ require ( github.com/google/go-cmp v0.7.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/ianlancetaylor/jsonschema v0.0.0-20251021232724-46ecbf32a0a5 // indirect - github.com/klauspost/compress v1.18.2 // indirect + github.com/klauspost/compress v1.18.5 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/magiconair/properties v1.8.10 // indirect github.com/matoous/go-nanoid/v2 v2.1.0 // indirect @@ -58,6 +58,7 @@ require ( github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect github.com/shirou/gopsutil/v4 v4.26.2 // indirect github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spf13/cast v1.10.0 // indirect github.com/stretchr/testify v1.11.1 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect github.com/tklauser/numcpus v0.11.0 // indirect diff --git a/go.sum b/go.sum index 1f039fe..7ccade3 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,18 @@ dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= git.gsuntres.com/general/commons v0.0.0-20260329171253-65eec3c3b1e3 h1:BMs+fuAzLvvuZFFUYruUZxdPhFOxzLRwRXPwkkkTNrw= git.gsuntres.com/general/commons v0.0.0-20260329171253-65eec3c3b1e3/go.mod h1:j+Iy310zO6jFrqXgMLIlAJeMIc332AHnoRUhsIroN/4= +git.gsuntres.com/general/commons v0.0.0-20260402010100-7e8cf14bb0a5 h1:iDZS0uQComRTiYxinclK73RoyI3Fsk3xNuAIWqN9590= +git.gsuntres.com/general/commons v0.0.0-20260402010100-7e8cf14bb0a5/go.mod h1:ZawSPCI/Irjx7P83qJRcknKGuLLJ9c7hhP4OXgILnCY= git.gsuntres.com/general/mongo v0.0.0-20260329164619-eff6c4ecee15 h1:MD2fRF3oIQ7g/ToW+toCZH3/LL8bBsSz9PhEQyjOpk0= git.gsuntres.com/general/mongo v0.0.0-20260329164619-eff6c4ecee15/go.mod h1:AUb/BDG+dVPHpKmO5GsoZqIbDO8uqbxBabEqtqAB4tw= git.gsuntres.com/general/structful v0.0.0-20260330181942-47f7fdf9c083 h1:Z4zgJfWbcfnUiE1NjqMukUMYYlpN/10DUFpu4u789eQ= git.gsuntres.com/general/structful v0.0.0-20260330181942-47f7fdf9c083/go.mod h1:yAdT20C09rz2VHA6ALurxc2KUaF03cSqvmRvDwv+KZk= +git.gsuntres.com/general/structful v0.0.0-20260402004702-c83e44b04a9f h1:bJpj6N9a2fBlcwMFoG+egkDsAmNbjfzdz3arzbdgzHs= +git.gsuntres.com/general/structful v0.0.0-20260402004702-c83e44b04a9f/go.mod h1:fB5HAdx2wWMUkTitRz729EhpASpiHrgTYdIKQugVMjs= git.gsuntres.com/general/sys v0.0.0-20260329160429-49966ca31027 h1:4pmcjxEDM4rzv+iimQ7wTgCAQ1VnAoeGiHLuf6wC6Fw= git.gsuntres.com/general/sys v0.0.0-20260329160429-49966ca31027/go.mod h1:OVs7w4/tJO1GT7cLIeEsb90LuZqH2xYIVQODI5P1GJs= +git.gsuntres.com/general/sys v0.0.1 h1:JpGG6HCkJrTaCICR09kURhMTIc+/s8yb0lHQjo/TDVI= +git.gsuntres.com/general/sys v0.0.1/go.mod h1:OVs7w4/tJO1GT7cLIeEsb90LuZqH2xYIVQODI5P1GJs= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= @@ -67,6 +73,8 @@ github.com/ianlancetaylor/jsonschema v0.0.0-20251021232724-46ecbf32a0a5 h1:x2QxK github.com/ianlancetaylor/jsonschema v0.0.0-20251021232724-46ecbf32a0a5/go.mod h1:KtN3dTgXsLnC5GJBRNmOPd/HUInNcQ84lUCrKJPrvDc= github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= +github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE= +github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -111,6 +119,8 @@ github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cI github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= +github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= diff --git a/persist.go b/persist.go index cea748d..afd811e 100644 --- a/persist.go +++ b/persist.go @@ -7,9 +7,7 @@ import ( "fmt" "errors" "reflect" - "golang.org/x/text/cases" - "golang.org/x/text/language" - + "github.com/go-viper/mapstructure/v2" "go.mongodb.org/mongo-driver/v2/bson" @@ -49,8 +47,6 @@ var deferedFuncs map[string]any = make(map[string]any, 0) var persist any -var caseString cases.Caser = cases.Title(language.English) - type InitProps struct { MongoSysDb string } diff --git a/persist_deleteone.go b/persist_deleteone.go index 0ef4946..bbb4a10 100644 --- a/persist_deleteone.go +++ b/persist_deleteone.go @@ -5,6 +5,7 @@ import ( "context" "reflect" + "git.gsuntres.com/general/commons" "git.gsuntres.com/general/mongo" ) @@ -24,7 +25,7 @@ func BuildDeleteOne(col map[string]any) { // create function signature variadic := false funcType := reflect.FuncOf(in, out, variadic) - deleteOneName := fmt.Sprintf("%s%s", "Delete", caseString.String(singular)) + deleteOneName := fmt.Sprintf("%s%s", "Delete", commons.StringTitle(singular)) fields = append(fields, reflect.StructField{ Name: deleteOneName, Type: funcType, diff --git a/persist_find.go b/persist_find.go index 7e2d5b2..d2e3311 100644 --- a/persist_find.go +++ b/persist_find.go @@ -7,6 +7,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" + "git.gsuntres.com/general/commons" "git.gsuntres.com/general/mongo" ) @@ -28,7 +29,7 @@ func BuildFind(col map[string]any) { // create function signature variadic := false funcType := reflect.FuncOf(in, out, variadic) - funcName := fmt.Sprintf("%s%s", "Find", caseString.String(plural)) + funcName := fmt.Sprintf("%s%s", "Find", commons.StringTitle(plural)) fields = append(fields, reflect.StructField{ Name: funcName, Type: funcType, diff --git a/persist_findone.go b/persist_findone.go index 04b277d..20662f5 100644 --- a/persist_findone.go +++ b/persist_findone.go @@ -7,6 +7,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" + "git.gsuntres.com/general/commons" "git.gsuntres.com/general/mongo" ) @@ -27,7 +28,7 @@ func BuildFindOne(col map[string]any) { // create function signature variadic := false funcType := reflect.FuncOf(in, out, variadic) - funcName := fmt.Sprintf("%s%s", "Find", caseString.String(singular)) + funcName := fmt.Sprintf("%s%s", "Find", commons.StringTitle(singular)) fields = append(fields, reflect.StructField{ Name: funcName, Type: funcType, diff --git a/persist_getone.go b/persist_getone.go index 5745baa..737ee08 100644 --- a/persist_getone.go +++ b/persist_getone.go @@ -7,6 +7,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" + "git.gsuntres.com/general/commons" "git.gsuntres.com/general/mongo" ) @@ -27,7 +28,7 @@ func BuildGetOne(col map[string]any) { // create function signature variadic := false funcType := reflect.FuncOf(in, out, variadic) - funcName := fmt.Sprintf("%s%s", "Get", caseString.String(singular)) + funcName := fmt.Sprintf("%s%s", "Get", commons.StringTitle(singular)) fields = append(fields, reflect.StructField{ Name: funcName, Type: funcType, diff --git a/persist_insertone.go b/persist_insertone.go index 3b0b0e0..9700b22 100644 --- a/persist_insertone.go +++ b/persist_insertone.go @@ -7,6 +7,7 @@ import ( "go.mongodb.org/mongo-driver/v2/bson" + "git.gsuntres.com/general/commons" "git.gsuntres.com/general/mongo" ) @@ -27,7 +28,7 @@ func BuildInsertOne(col map[string]any) { // create function signature variadic := false funcType := reflect.FuncOf(in, out, variadic) - insertOneName := fmt.Sprintf("%s%s", "Insert", caseString.String(singular)) + insertOneName := fmt.Sprintf("%s%s", "Insert", commons.StringTitle(singular)) fields = append(fields, reflect.StructField{ Name: insertOneName, Type: funcType,