lang: funcs: funcgen: Allow []string as inputs

This allows us to have the strings.Join function generated.
This commit is contained in:
James Shubin
2023-11-25 20:57:34 -05:00
parent ce2f7112a3
commit af1c952700
6 changed files with 76 additions and 6 deletions

View File

@@ -101,18 +101,19 @@ func generateTemplate(c config, f functions, path, templateFile, finalName strin
func (obj *function) MakeGolangArgs() (string, error) {
var args []string
for i, a := range obj.Args {
gol, err := a.ToGolang()
input := fmt.Sprintf("input[%d]", i)
gol, err := a.ToGolang(input)
if err != nil {
return "", err
}
input := fmt.Sprintf("input[%d].%s()", i, gol)
switch a.Type {
case "int":
input = fmt.Sprintf("int(%s)", input)
gol = fmt.Sprintf("int(%s)", gol)
case "[]byte":
input = fmt.Sprintf("[]byte(%s)", input)
gol = fmt.Sprintf("[]byte(%s)", gol)
}
args = append(args, input)
args = append(args, gol)
}
for _, a := range obj.ExtraGolangArgs {
args = append(args, a.Value)