Skip to content

Commit 6a3e9ae

Browse files
Fix hyphen in go struct names (#2305)
Co-authored-by: Zhengyang Feng <nuoyiman00@gmail.com>
1 parent bdea5bd commit 6a3e9ae

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/codegen/golang/struct.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ func StructName(name string, settings *plugin.Settings) string {
1919
if rename := settings.Rename[name]; rename != "" {
2020
return rename
2121
}
22-
out := ""
23-
for _, p := range strings.Split(name, "_") {
22+
var (
23+
out string
24+
fn = func(r rune) bool {
25+
return r == '_' || r == '-'
26+
}
27+
)
28+
for _, p := range strings.FieldsFunc(name, fn) {
2429
if p == "id" {
2530
out += "ID"
2631
} else {

0 commit comments

Comments
 (0)