Skip to content

Commit

Permalink
Fix hyphen in go struct names (#2305)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhengyang Feng <nuoyiman00@gmail.com>
  • Loading branch information
kyleconroy and zhengyangfeng00 committed Jun 7, 2023
1 parent bdea5bd commit 6a3e9ae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/codegen/golang/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ func StructName(name string, settings *plugin.Settings) string {
if rename := settings.Rename[name]; rename != "" {
return rename
}
out := ""
for _, p := range strings.Split(name, "_") {
var (
out string
fn = func(r rune) bool {
return r == '_' || r == '-'
}
)
for _, p := range strings.FieldsFunc(name, fn) {
if p == "id" {
out += "ID"
} else {
Expand Down

0 comments on commit 6a3e9ae

Please sign in to comment.