12345678910111213141516171819202122232425262728293031323334353637 |
- package got
- import (
- "text/template"
- . "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/common"
- )
- var (
- hookStmtsTmpl *template.Template
- hookStmtsErr error
- )
- func init() {
- hookStmtsTmpl, hookStmtsErr = ParseTemplate(`
- import(
- {{range $label, $path := .imports}}
- {{$label}} "{{$path}}"
- {{end}}
- )
- {{if .hasContext}}
- func {{.function}}(options map[string]interface{}) func( context.Context) (interface{},*errs.Error) {
- return func(ctx context.Context) (resp interface{}, err *errs.Error) {
- return
- }
- }
- {{else}}
- func {{.function}}(ctx context.Context) (resp interface{}, err *errs.Error) {
- return
- }
- {{end}}
- `)
- if hookStmtsErr != nil {
- panic(hookStmtsErr)
- }
- }
|