Version: v0.0.0-...-8ddf78f Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 4 Imported by: 0




View Source
const (
	OKCode int = iota

linq-related error codes


View Source
var (
	ErrDupKeys      = &Error{code: DupKeysCode, msg: "duplicate keys"}
	ErrEmptyEnum    = &Error{code: EmptyEnumCode, msg: "enum is empty"}
	ErrIdxRange     = &Error{code: IdxRangeCode, msg: "index is out of range"}
	ErrMultiElems   = &Error{code: MultiElemsCode, msg: "enum contains multiple elements"}
	ErrMultiMatch   = &Error{code: MultiMatchCode, msg: "enum contains multiple matching elements"}
	ErrNegCount     = &Error{code: NegCountCode, msg: "count is negative"}
	ErrNilAcc       = &Error{code: NilAccCode, msg: "accumulator is nil"}
	ErrNilCmp       = &Error{code: NilCmpCode, msg: "comparison is nil"}
	ErrNilEnum      = &Error{code: NilEnumCode, msg: "enum is nil"}
	ErrNilEq        = &Error{code: NilEqCode, msg: "equality is nil"}
	ErrNilKey       = &Error{code: NilKeyCode, msg: "key is nil"}
	ErrNilLess      = &Error{code: NilLessCode, msg: "less is nil"}
	ErrNilPred      = &Error{code: NilPredCode, msg: "predicate is nil"}
	ErrNilSel       = &Error{code: NilSelCode, msg: "selector is nil"}
	ErrNoMatch      = &Error{code: NoMatchCode, msg: "no items match the predicate"}
	ErrStrtCntRange = &Error{code: StrtCntRangeCode, msg: "start and/or count are out of range"}

linq-related errors.

View Source
var CaseInsensitiveCmp = func(e1, e2 Elem) int {
	s1 := strings.ToLower(e1.(string))
	s2 := strings.ToLower(e2.(string))
	if s1 < s2 {
		return -1
	if s1 > s2 {
		return +1
	return 0

CaseInsensitiveCmp is a case-insensitive Comparison for strings.

View Source
var CaseInsensitiveEq = func(e1, e2 Elem) bool {
	return strings.ToLower(e1.(string)) == strings.ToLower(e2.(string))

CaseInsensitiveEq is a case-insensitive Equality for strings.

View Source
var Identity = func(el Elem) Elem {
	return el

Identity is an identity selector.


This section is empty.


type Comparison

type Comparison = func(Elem, Elem) int

Comparison compares two Elems and returns negative if the first Elem is less than the second one, zero if the first Elem is equal to the second one and positive if the first Elem is greater than the second one (see

func LessToComparison

func LessToComparison(ls Less) Comparison

LessToComparison converts Less to Comparison.

type DeEnum

type DeEnum struct {
	// contains filtered or unexported fields

DeEnum is a sequence of Elems with stop field.

func NewDeEnum

func NewDeEnum(ee ...Elem) *DeEnum

NewDeEnum creates DeEnum with 'ee' contents.

func NewEmptyDeEnum

func NewEmptyDeEnum() *DeEnum

NewEmptyDeEnum returns new empty non-nil Enum.

func (*DeEnum) SelectEr

func (en *DeEnum) SelectEr(sel Selector) (<-chan Elem, error)

SelectEr replicates linq.SelectEr but with deferred execution.

func (*DeEnum) Stop

func (en *DeEnum) Stop()

Stop stops iteration over DeEnum.

type Elem

type Elem = interface{}

Elem is a type of Enum elements.

type Equality

type Equality = func(Elem, Elem) bool

Equality determines whether the specified Elems are equal or not.

type Error

type Error struct {
	// contains filtered or unexported fields

Error represents linq error and implements Errorer interface.

func NotSameTypeError

func NotSameTypeError(t1, t2 reflect.Type) *Error

NotSameTypeError erroneous situation elems have not same type.

func WrongTypeError

func WrongTypeError(el Elem, i interface{}) *Error

WrongTypeError denotes erroneous situation when Elem has wrong type.

func (*Error) Code

func (e *Error) Code() int

Code returns error code.

func (*Error) Error

func (e *Error) Error() string

type Errorer

type Errorer interface {

	Code() int
	// contains filtered or unexported methods

Errorer interface identifies a linq error. All errors returned by linq package implement Errorer interface.

type Less

type Less = func(Elem, Elem) bool

Less determines whether the first specified Elem is less than the second one.

type Predicate

type Predicate = func(Elem) bool

Predicate projects an element into bool.

type PredicateIdx

type PredicateIdx = func(Elem, int) bool

PredicateIdx projects an element and its index into bool.

type Selector

type Selector = func(Elem) Elem

Selector projects an element into another.

type SelectorIdx

type SelectorIdx = func(Elem, int) Elem

SelectorIdx projects an element and its index into another element.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL