gapr/options.go

38 lines
538 B
Go
Raw Normal View History

2023-01-30 21:06:18 +00:00
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
}