26 lines
540 B
Smarty
26 lines
540 B
Smarty
func With{{.StructName}}Log(log func(context.Context, string, ...any)) func(*{{.StructName}}) {
|
|
return func(ci *{{.StructName}}) {
|
|
ci.log = log
|
|
}
|
|
}
|
|
|
|
func New{{.StructName}}(prov config.Provider, opts ...func(*{{.StructName}})) {{.StructName}} {
|
|
i := {{.StructName}}{
|
|
Provider: prov,
|
|
log: func(_ context.Context, format string, args ...any) {
|
|
fmt.Printf(format, args...)
|
|
},
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
opt(&i)
|
|
}
|
|
|
|
return i
|
|
}
|
|
|
|
type {{.StructName}} struct {
|
|
config.Provider
|
|
log func(context.Context, string, ...any)
|
|
}
|