aboutsummaryrefslogtreecommitdiff
path: root/factory/factory.go
blob: ae849116d200d710fdb9b4d3455bed0dfaec3254 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}