ingress-nginx-helm/vendor/github.com/ncabatoff/go-seq
Manuel Alejandro de Brito Fontes f4a4daed84 Update go dependencies
2018-12-05 13:27:09 -03:00
..
seq Update go dependencies 2018-12-05 13:27:09 -03:00
.travis.yml Update go dependencies 2018-12-05 13:27:09 -03:00
LICENSE Update go dependencies 2018-12-05 13:27:09 -03:00
README.md Update go dependencies 2018-12-05 13:27:09 -03:00

Package for ordering of Go values

GoDoc Build Status Coverage Status

This package is intended to allow ordering (most) values via reflection, much like go-cmp allows comparing values for equality.

This is helpful when trying to write Less() methods for sorting structures. Provided all the types in question are supported, you can simply define it as follows:

import "github.com/ncabatoff/go-seq/seq"

type (
    MyType struct {
        a int
        b string
    }
    MyTypeSlice []MyType
)
func (m MyTypeSlice) Less(i, j int) bool { return seq.Compare(m[i], m[j]) < 0 }

Noteable unsupported types include the builtin complex type, channels, functions, and maps with non-string keys. Pointers can be ordered if their underlying types are orderable.

Install

go get -u github.com/ncabatoff/go-seq/seq

License

MIT - See LICENSE file