From bd9219ddac4d558aff036076a6b6959e920c491d Mon Sep 17 00:00:00 2001 From: khudayberdiyev25 <52091877+khudayberdiyev25@users.noreply.github.com> Date: Tue, 28 May 2024 17:29:17 +0500 Subject: [PATCH] Go template function to split string into array of strings. (#3108) * added new template function to split string * StrSplit func to upper --------- Co-authored-by: otabek --- codegen/templates/templates.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codegen/templates/templates.go b/codegen/templates/templates.go index 115ef7872f6..f2c367cb3b4 100644 --- a/codegen/templates/templates.go +++ b/codegen/templates/templates.go @@ -206,6 +206,7 @@ func Funcs() template.FuncMap { "call": Call, "prefixLines": prefixLines, "notNil": notNil, + "strSplit": StrSplit, "reserveImport": CurrentImports.Reserve, "lookupImport": CurrentImports.Lookup, "go": ToGo, @@ -581,6 +582,10 @@ func notNil(field string, data any) bool { return val.IsValid() && !val.IsNil() } +func StrSplit(s, sep string) []string { + return strings.Split(s, sep) +} + func Dump(val any) string { switch val := val.(type) { case int: