Files
open-im-server/pkg/common/localcache/option/option.go
T

34 lines
454 B
Go
Raw Normal View History

2024-01-08 16:47:39 +08:00
package option
2024-01-08 20:36:41 +08:00
func NewOption() *Option {
return &Option{}
}
2024-01-08 16:47:39 +08:00
type Option struct {
2024-01-08 20:36:41 +08:00
Enable *bool
Link []string
2024-01-08 16:47:39 +08:00
}
2024-01-08 20:36:41 +08:00
func (o *Option) WithEnable() *Option {
t := true
o.Enable = &t
2024-01-08 16:47:39 +08:00
return o
}
2024-01-08 20:36:41 +08:00
func (o *Option) WithDisable() *Option {
f := false
o.Enable = &f
2024-01-08 16:47:39 +08:00
return o
}
2024-01-08 20:36:41 +08:00
func (o *Option) WithLink(key ...string) *Option {
2024-01-08 16:47:39 +08:00
if len(key) > 0 {
2024-01-08 20:36:41 +08:00
if len(o.Link) == 0 {
o.Link = key
2024-01-08 16:47:39 +08:00
} else {
2024-01-08 20:36:41 +08:00
o.Link = append(o.Link, key...)
2024-01-08 16:47:39 +08:00
}
}
return o
}