This commit is contained in:
cubixle
2021-06-18 21:06:02 +01:00
parent f435f65536
commit f330903f9e
13 changed files with 85 additions and 26 deletions

26
templates/service.go.tmpl Normal file
View File

@@ -0,0 +1,26 @@
package service
import ({{ range .Imports }}
"{{ . }}"{{ end }}
)
func New() *Service {
return &Service{}
}
type Service struct {
interactor *interactors.Interactor
}
{{ range .Funcs }}
func (s *Service) {{ .Name }}({{.ArgsToStr}}) {{ if gt (len .Returns) 0 }}({{.ListToStr .Returns}}){{end}} {
res, err := s.interactor.{{.Name}}(ctx, req)
if err != nil {
return nil, errorToGRPCError(err)
}
return res, nil
}
{{ end }}
func errorToGRPCError(err error) error {
return err
}