Documentation ¶
Overview ¶
* @Author: Wangjun * @Date: 2021-05-15 22:43:20 * @LastEditTime: 2022-05-20 14:58:51 * @LastEditors: Wangjun * @Description: * @FilePath: \golib\sliceutil\getter.go * hnxr
Index ¶
- func Asc(slice interface{}, name string) (err error)
- func Desc(slice interface{}, name string) (err error)
- func OrderBy(slice interface{}, key string, order string)
- func Where(slice interface{}, name string, value interface{}, isReg ...bool) (idx int, err error)
- func WhereMap(mp map[string]string, slices interface{}, isReg ...bool) interface{}
- type Getter
- type Ordering
- type Sorter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Getter ¶
A Getter is a function which takes a reflect.Value for a slice, and returns a a slice of reflect.Value, e.g. a slice with a reflect.Value for each of the Name fields from a reflect.Value for a slice of a struct type. It is used by the sort functions to identify the elements to sort by.
func FieldGetter ¶
FieldGetter Returns a Getter which gets fields with name from a reflect.Value for a slice of a struct type, returning them as a slice of reflect.Value (one Value for each field in each struct.) Can be used with Sort to sort an []Object by e.g. Object.Name or Object.Date. A runtime panic will occur if the specified field isn't exported.
type Ordering ¶
type Ordering int
Ordering decides the order in which the specified data is sorted.
A runtime panic will occur if case-insensitive is used when not sorting by a string type.
type Sorter ¶
type Sorter struct { Slice reflect.Value Ordering Ordering // contains filtered or unexported fields }
Sorter A reflecting sort.Interface adapter.