Skip to content

Commit

Permalink
Fixed generation
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet committed Dec 30, 2024
1 parent a0cb0e3 commit c28eac6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion field_build_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,11 @@ func (c *FieldBuildContext) GetOneOfFieldName() string {
return ""
}

return c.desc.OneofDecl[*c.field.OneofIndex].GetName()
name := c.desc.OneofDecl[*c.field.OneofIndex].GetName()
if name[0:1] == strings.ToLower(name[0:1]) {
return strcase.UpperCamelCase(name)
}
return name
}

// GetOneOfTypeName returns OneOf container go name
Expand Down
7 changes: 6 additions & 1 deletion message_build_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
"github.com/stoewer/go-strcase"
)

const (
Expand Down Expand Up @@ -137,7 +138,11 @@ func (c *MessageBuildContext) GetInjectedFields() []InjectedField {
func (c *MessageBuildContext) GetOneOfNames() []string {
s := make([]string, len(c.desc.OneofDecl))
for i, d := range c.desc.OneofDecl {
s[i] = d.GetName()
name := d.GetName()
if name[0:1] == strings.ToLower(name[0:1]) {
name = strcase.UpperCamelCase(name)
}
s[i] = name
}
return s
}
Expand Down
10 changes: 5 additions & 5 deletions test/test_terraform.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c28eac6

Please sign in to comment.