package factory import ( "github.com/rs/zerolog" "www.thenautilus.net/cgit/go-example/config" "www.thenautilus.net/cgit/go-example/something" ) type Factory struct { something *something.Something config *config.MainConfig logger zerolog.Logger } func New(logger zerolog.Logger, config *config.MainConfig) Factory { return Factory{ config: config, logger: logger, } } func (f *Factory) Something() *something.Something { if f.something == nil { something := something.New( &f.config.Something, ) f.something = &something } return f.something }