Skip to content

Commit

Permalink
Go template function to split string into array of strings. (#3108)
Browse files Browse the repository at this point in the history
* added new template function to split string

* StrSplit func to upper

---------

Co-authored-by: otabek <kh.otabek@iman.uz>
  • Loading branch information
khudayberdiyev25 and otabek committed May 28, 2024
1 parent 6c83b9e commit bd9219d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions codegen/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func Funcs() template.FuncMap {
"call": Call,
"prefixLines": prefixLines,
"notNil": notNil,
"strSplit": StrSplit,
"reserveImport": CurrentImports.Reserve,
"lookupImport": CurrentImports.Lookup,
"go": ToGo,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit bd9219d

Please sign in to comment.