From 8278a3e80a6a52973fe34f17a380863ae955ac5d Mon Sep 17 00:00:00 2001 From: Bill Rose Date: Fri, 19 Aug 2022 11:10:34 -0400 Subject: [PATCH] Re-generate to satisfy the linter --- _examples/selection/models_gen.go | 48 ++++++++++++++++--- .../modelgen/out_struct_pointers/generated.go | 33 +++++++++++++ 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/_examples/selection/models_gen.go b/_examples/selection/models_gen.go index f898a183d1..3a66264849 100644 --- a/_examples/selection/models_gen.go +++ b/_examples/selection/models_gen.go @@ -19,9 +19,27 @@ type Like struct { Collected []string `json:"collected"` } -func (Like) IsEvent() {} -func (this Like) GetSelection() []string { return this.Selection } -func (this Like) GetCollected() []string { return this.Collected } +func (Like) IsEvent() {} +func (this Like) GetSelection() []string { + if this.Selection == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Selection)) + for _, concrete := range this.Selection { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this Like) GetCollected() []string { + if this.Collected == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Collected)) + for _, concrete := range this.Collected { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} type Post struct { Message string `json:"message"` @@ -30,6 +48,24 @@ type Post struct { Collected []string `json:"collected"` } -func (Post) IsEvent() {} -func (this Post) GetSelection() []string { return this.Selection } -func (this Post) GetCollected() []string { return this.Collected } +func (Post) IsEvent() {} +func (this Post) GetSelection() []string { + if this.Selection == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Selection)) + for _, concrete := range this.Selection { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this Post) GetCollected() []string { + if this.Collected == nil { + return nil + } + interfaceSlice := make([]string, 0, len(this.Collected)) + for _, concrete := range this.Collected { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} diff --git a/plugin/modelgen/out_struct_pointers/generated.go b/plugin/modelgen/out_struct_pointers/generated.go index 4b7b650f8b..3b311c64d0 100644 --- a/plugin/modelgen/out_struct_pointers/generated.go +++ b/plugin/modelgen/out_struct_pointers/generated.go @@ -13,6 +13,12 @@ type A interface { GetA() string } +type ArrayOfA interface { + IsArrayOfA() + GetTrickyField() []A + GetTrickyFieldPointer() []A +} + type B interface { IsB() GetB() int @@ -101,6 +107,33 @@ type FieldMutationHook struct { Repeated *string `json:"repeated" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` } +type ImplArrayOfA struct { + TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` + TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer" database:"ImplArrayOfAtrickyFieldPointer"` +} + +func (ImplArrayOfA) IsArrayOfA() {} +func (this ImplArrayOfA) GetTrickyField() []A { + if this.TrickyField == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyField)) + for _, concrete := range this.TrickyField { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} +func (this ImplArrayOfA) GetTrickyFieldPointer() []A { + if this.TrickyFieldPointer == nil { + return nil + } + interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) + for _, concrete := range this.TrickyFieldPointer { + interfaceSlice = append(interfaceSlice, concrete) + } + return interfaceSlice +} + type MissingInput struct { Name *string `json:"name" database:"MissingInputname"` Enum *MissingEnum `json:"enum" database:"MissingInputenum"`