home/private_dot_config/boilr/templates/fx/template/component.go

37 lines
444 B
Go

{{- $pkg := env "PWD" | base | coalesce Package -}}
package {{$pkg}}
import (
"context"
"log/slog"
"go.uber.org/fx"
)
type {{title $pkg}} struct {
log *slog.Logger
}
type Params struct {
fx.In
Ctx context.Context
Lc fx.Lifecycle
Log *slog.Logger
}
type Result struct {
fx.Out
Output *{{title $pkg}}
}
func New(p Params) (r Result, err error) {
o := &{{title $pkg}}{}
o.log = p.Log
r.Output = o
return
}