-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoption.go
More file actions
48 lines (38 loc) · 709 Bytes
/
option.go
File metadata and controls
48 lines (38 loc) · 709 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
47
48
package bcl
import (
"io"
"os"
)
type Option func(*config)
type config struct {
disasm bool
trace bool
stats bool
output io.Writer
logw io.Writer
}
func makeConfig(oo []Option) (cf config) {
cf = config{
output: os.Stdout,
logw: os.Stderr,
}
for _, o := range oo {
o(&cf)
}
return cf
}
func OptDisasm(x bool) Option {
return func(cf *config) { cf.disasm = x }
}
func OptTrace(x bool) Option {
return func(cf *config) { cf.trace = x }
}
func OptStats(x bool) Option {
return func(cf *config) { cf.stats = x }
}
func OptOutput(w io.Writer) Option {
return func(cf *config) { cf.output = w }
}
func OptLogger(w io.Writer) Option {
return func(cf *config) { cf.logw = w }
}