package searcher // Opter Opter type Opter interface { SetSkip(v int64) Opter Skip() int64 SetLimit(v int64) Opter Limit() int64 SetSort(key string, v int64) Opter Sort() D } type Option struct { skip *int64 limit *int64 sort D } const MaxLimit = 50 const MinLimit = 1 func (o *Option) Skip() int64 { if o.skip == nil { return 0 } return *o.skip } func (o *Option) SetSkip(v int64) Opter { o.skip = &v return o } func (o *Option) Limit() int64 { if o.limit == nil { return MinLimit } if *o.limit > MaxLimit { return MaxLimit } return *o.limit } func (o *Option) SetLimit(v int64) Opter { o.limit = &v return o } func (o *Option) Sort() D { return o.sort } func (o *Option) SetSort(key string, v int64) Opter { o.sort = append(o.sort, E{Key: key, Value: v}) return o }