github.com/clubpay/ronykit/kit@v0.14.4-0.20240515065620-d0dace45cbc7/stub/stubgen/gen_func.go (about) 1 package stubgen 2 3 import ( 4 "strings" 5 6 "github.com/clubpay/ronykit/kit/internal/tpl" 7 ) 8 9 // GenFunc is the function which generates the final code. For example to generate 10 // golang code use GolangStub 11 type GenFunc func(in Input) (string, error) 12 13 func GolangStub(in Input) (string, error) { 14 sb := &strings.Builder{} 15 16 err := tpl.GoStub.Execute(sb, in) 17 if err != nil { 18 return "", err 19 } 20 21 return sb.String(), nil 22 } 23 24 func TypeScriptStub(in Input) (string, error) { 25 sb := &strings.Builder{} 26 27 err := tpl.TsStub.Execute(sb, in) 28 if err != nil { 29 return "", err 30 } 31 32 return sb.String(), nil 33 }