Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotSlice is returned when NewCyclerFromSlice was not passed a input of type slice. ErrNotSlice = errors.New("values is not a slice") // ErrNoValues is returned when a cycler was initialized with no values. ErrNoValues = errors.New("no configured values") )
Functions ¶
This section is empty.
Types ¶
type Cycler ¶
type Cycler interface { // Get returns the current value in the cycler. It does not rotate the cycler. Get() interface{} // Next rotates the cycler and returns the next value. Next() interface{} // Seek rotates the cycler until it finds a specific value. // If the values is not found the cycler will remain in the same index. Seek(target interface{}) interface{} // Len returns the number of values in the cycler. Len() int }
Cycler provides a way to cycle through a set of elements.
func NewCycler ¶
NewCycler creates a Cycler from passed values. This will return an error if no elements are passed.
func NewCyclerFromSlice ¶
NewCyclerFromSlice creates a Cycler from a slice. The cycler will contain all the elements in the slice. This will return an error if `values` is not a slice or if the slice does not contain any elements.
Click to show internal directories.
Click to hide internal directories.