38 lines
538 B
Go
38 lines
538 B
Go
|
package gapr
|
||
|
|
||
|
import "time"
|
||
|
|
||
|
func WithRandomSeed(i int64) Option {
|
||
|
return optionFunc(func(o *options) {
|
||
|
o.RandomSeed = i
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func WithTagName(tag string) Option {
|
||
|
return optionFunc(func(o *options) {
|
||
|
o.TagName = tag
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func defaultOptions() options {
|
||
|
return options{
|
||
|
TagName: "gapr",
|
||
|
RandomSeed: time.Now().UTC().Unix(),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type Option interface {
|
||
|
apply(o *options)
|
||
|
}
|
||
|
|
||
|
type optionFunc func(o *options)
|
||
|
|
||
|
func (f optionFunc) apply(o *options) {
|
||
|
f(o)
|
||
|
}
|
||
|
|
||
|
type options struct {
|
||
|
TagName string
|
||
|
RandomSeed int64
|
||
|
}
|