gapr/options.go
Peter ec31dd14d4
All checks were successful
concourse-ci/lint/golangci-lint Lint Go files
refactor: apply golangci-lint findings
2023-01-31 21:14:34 +01:00

46 lines
677 B
Go

package gapr
import "time"
func WithRandomSeed(i int64) optionFunc {
return func(o *options) {
o.RandomSeed = i
}
}
func WithTagName(tag string) optionFunc {
return func(o *options) {
o.TagName = tag
}
}
func WithMapper(mapper KeyMapper) optionFunc {
return func(o *options) {
o.Mapper = mapper
}
}
func defaultOptions() options {
return options{
TagName: "gapr",
RandomSeed: time.Now().UTC().Unix(),
Mapper: identityKeyMapper,
}
}
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
Mapper KeyMapper
}