-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.go
More file actions
46 lines (39 loc) · 775 Bytes
/
options.go
File metadata and controls
46 lines (39 loc) · 775 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
package geoipfix
import (
"github.com/fiorix/freegeoip"
"go.uber.org/zap"
)
// option is a functional option.
type option func(*options)
// NewOptions initializes geoipfix options.
func newOptions(opts ...option) options {
opt := options{}
for _, o := range opts {
o(&opt)
}
return opt
}
// options are geoipfix options.
type options struct {
DB *freegeoip.DB
Logger *zap.Logger
Debug bool
}
// withDB sets the database.
func withDB(db *freegeoip.DB) option {
return func(o *options) {
o.DB = db
}
}
// withDebug sets the debug flag.
func withDebug(debug bool) option {
return func(o *options) {
o.Debug = debug
}
}
// withLogger sets the logger.
func withLogger(logger *zap.Logger) option {
return func(o *options) {
o.Logger = logger
}
}