Skip to content

Commit 672d491

Browse files
committed
allow renaming function Params structs
1 parent 047d587 commit 672d491

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/codegen/golang/result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func putOutColumns(query *plugin.Query) bool {
353353
// This is unlikely to happen, so don't fix it yet
354354
func columnsToStruct(req *plugin.GenerateRequest, options *opts.Options, name string, columns []goColumn, useID bool) (*Struct, error) {
355355
gs := Struct{
356-
Name: name,
356+
Name: CheckRename(name, options),
357357
}
358358
seen := map[string][]int{}
359359
suffixes := map[int]int{}

internal/codegen/golang/struct.go

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package golang
22

33
import (
4+
"log/slog"
45
"strings"
56
"unicode"
67
"unicode/utf8"
@@ -16,6 +17,14 @@ type Struct struct {
1617
Comment string
1718
}
1819

20+
func CheckRename(name string, options *opts.Options) string {
21+
if rename := options.Rename[name]; rename != "" {
22+
slog.Info("CheckRename", slog.String("original", name), slog.String("rename", rename))
23+
return rename
24+
}
25+
return name
26+
}
27+
1928
func StructName(name string, options *opts.Options) string {
2029
if rename := options.Rename[name]; rename != "" {
2130
return rename

0 commit comments

Comments
 (0)