Skip to content

Commit

Permalink
Fix gen'd Go code to consistently use args (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSGK authored Jun 20, 2024
1 parent 6538b6b commit 2bbdfc3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/gen/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,13 @@ func (g *goGenerator) genGoForFeature(ctx context.Context, r repo.ConfigurationR
}
data.CallString = "args"
} else {
data.CtxStuff = "ctx := context.Background()\n"
data.CtxStuff = "args := context.Background()\n"
data.NaturalLanguage = g.translateFeature(f, protoType, false, usedVariables, &generated.usedStrings, &generated.usedSlices)
var arguments []string
var ctxAddLines []string
for f, t := range usedVariables {
arguments = append(arguments, fmt.Sprintf("%s %s", strcase.ToLowerCamel(f), t))
ctxAddLines = append(ctxAddLines, fmt.Sprintf("ctx = client.Add(ctx, \"%s\", %s)", f, strcase.ToLowerCamel(f)))
ctxAddLines = append(ctxAddLines, fmt.Sprintf("args = client.Add(args, \"%s\", %s)", f, strcase.ToLowerCamel(f)))
}
// TODO: Sorting by name might not be the best solution for long-term UX... but it's simple and it works for now
slices.Sort(arguments)
Expand Down

0 comments on commit 2bbdfc3

Please sign in to comment.