blob: 41385cef0c84fc1d201a6792fe84fd51f37ceb1c (
plain) (
blame)
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
|
package qver
type Option func(*options)
type options struct {
parent *Version
UpdateFunc
state interface{}
}
func parse(opts ...Option) options {
var o options
for _, opt := range opts {
opt(&o)
}
return o
}
// Whenever the version changes, bump the parent's version as well.
func Parent(p *Version) Option {
return func(o *options) {
o.parent = p
}
}
// Call f(state) to update the version whenever Version.Get() is called.
func Update(state interface{}, f UpdateFunc) Option {
return func(o *options) {
o.UpdateFunc = f
o.state = state
}
}
|