easy

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 33 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NewMap     = gemap.NewMap
	NewSafeMap = gemap.NewSafeMap
)
View Source
var (
	MapKeys      = gemap.MapKeys
	MapValues    = gemap.MapValues
	IntKeys      = gemap.IntKeys
	IntValues    = gemap.IntValues
	StringKeys   = gemap.StringKeys
	StringValues = gemap.StringValues

	MergeMaps   = gemap.MergeMaps
	MergeMapsTo = gemap.MergeMapsTo
)
View Source
var NoHttp2Client = &http.Client{
	Transport: &http.Transport{
		DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
			return zeroDialer.DialContext(ctx, network, addr)
		},
		Dial: func(network, addr string) (net.Conn, error) {
			return zeroDialer.Dial(network, addr)
		},
	},
}

NoHttp2Client disables HTTP/2 feature by specifying a custom DialContext function, otherwise it behaves exactly same with http.NoHttp2Client.

HTTP/2 support in golang has many problematic corner cases where dead connections would be kept and used in connection pools. See:

https://github.com/golang/go/issues/32388
https://github.com/golang/go/issues/39337
https://github.com/golang/go/issues/39750

The deadlock reported by issue 32388 is observed in our production deployment, thus we disable HTTP/2 to help to get a better sleep.

Functions

func Caller

func Caller(skip int) (name, file string, line int)

Caller returns function name, filename, and the line number of the caller. The argument skip is the number of stack frames to ascend, with 0 identifying the caller of Caller.

func ConfigLog added in v0.2.10

func ConfigLog(cfg LogCfg)

func CopyStdLog

func CopyStdLog(f func()) []byte

CopyStdLog replaces the out Writer of the default logger of `log` package, and copies the content written to it. This is unsafe and most likely problematic, it's mainly to help intercepting log output in testing.

Also NOTE if the out Writer of the default logger has already been replaced with another writer, we won't know anything about that writer and will restore the out Writer to os.Stderr before it returns. It will be a real mess.

func CopyStdout

func CopyStdout(f func()) ([]byte, error)

CopyStdout replaces os.Stdout with a file created by `os.Pipe()`, and copies the content written to os.Stdout. This is not safe and most likely problematic, it's mainly to help intercepting output in testing.

func DEBUG

func DEBUG(args ...interface{})

DEBUG is debug message logger which do nothing if debug level is not enabled (the default). It gives best performance for production deployment by eliminating unnecessary parameter evaluation and control flows.

DEBUG accepts very flexible arguments to help development, see the following examples:

// func()
DEBUG(func() {
	logrus.Debug(something)
	for _, item := range someSlice {
		logrus.Debug(item)
	}
})

// logger from context with or without format
DEBUG(ctx, 1, 2, 3)
DEBUG(ctx, "a=%v b=%v c=%v", 1, 2, 3)

// log variables with or without format
DEBUG(1, 2, 3)
DEBUG("a=%v b=%v c=%v", 1, 2, 3)

// optionally a DebugLogger can be provided as the first parameter
logger := logrus.WithField("key", "dummy")
DEBUG(logger, "aa", 2, 3)
DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3)

// or a function which returns a logger implements DebugLogger
logger := func() *logrus.Entry { ... }
DEBUG(logger, "aa", 2, 3)
DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3)

// or a print function to print the log message
logger := logrus.Debugf
DEBUG(logger, "aa", 2, 3)
DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3)

// non-basic-type values will be formatted using json
obj := &SomeStructType{Field1: "blah", Field2: 1234567, Field3: true}
DEBUG(logger, "obj=%v", obj)

func DEBUGSkip

func DEBUGSkip(skip int, args ...interface{})

DEBUGSkip is similar to DEBUG, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".

func DUMP

func DUMP(args ...interface{})

DUMP is similar to DEBUG, but it calls spew.Sdump to format non-basic-type data.

func DUMPSkip added in v0.9.0

func DUMPSkip(skip int, args ...interface{})

DUMPSkip is similar to DUMP, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".

func DecodeJSON

func DecodeJSON(r io.Reader, v interface{}) error

DecodeJSON decodes a json value from r.

func DecodeXML

func DecodeXML(r io.Reader, v interface{}) error

DecodeXML decodes a XML value from r.

func DiffInt32s

func DiffInt32s(a []int32, b []int32) []int32

DiffInt32s returns a new int32 slice containing the values which present in slice a but not present in slice b.

func DiffInt64s

func DiffInt64s(a []int64, b []int64) []int64

DiffInt64s returns a new int64 slice containing the values which present in slice a but not present in slice b.

func DiffStrings

func DiffStrings(a []string, b []string) []string

DiffStrings returns a new string slice containing the values which present in slice a but not present in slice b.

func DoRequest

func DoRequest(req *Request) (respContent []byte, status int, err error)

DoRequest is a convenient function to send request and control redirect and debug options. If `Request.Resp` is provided, it will be used as destination to try to unmarshal the response body.

Trade-off was taken to balance simplicity and convenience of the function.

For more powerful controls of a http request and handy utilities, you may take a look at the awesome library `https://github.com/go-resty/resty/`.

func EnsureError

func EnsureError(v interface{}) error

EnsureError ensures the given value (should be non-nil) is an error. If it's not an error, `fmt.Errorf("%v", v)` will be used to convert it.

func FilterFunc added in v0.9.0

func FilterFunc(slice interface{}, predicate func(i int) bool) interface{}

FilterFunc iterates the given slice, it calls predicate(i) for i in range [0, n), where n is the length of the slice. It returns a new slice of elements for which predicate(i) returns true.

The parameter slice and predicate must not be nil, otherwise it panics.

func FilterInt32s added in v0.3.1

func FilterInt32s(slice []int32, predicate func(i int) bool) []int32

FilterInt32s iterates the given slice, it calls predicate(i) for i in range [0, n), where n is the length of the slice. It returns a new slice of elements for which predicate(i) returns true.

func FilterInt64s added in v0.3.1

func FilterInt64s(slice []int64, predicate func(i int) bool) []int64

FilterInt64s iterates the given slice, it calls predicate(i) for i in range [0, n), where n is the length of the slice. It returns a new slice of elements for which predicate(i) returns true.

func FilterStrings added in v0.3.1

func FilterStrings(slice []string, predicate func(i int) bool) []string

FilterStrings iterates the given slice, it calls predicate(i) for i in range [0, n), where n is the length of the slice. It returns a new slice of elements for which predicate(i) returns true.

func FindFunc added in v0.9.0

func FindFunc(slice interface{}, predicate func(i int) bool) interface{}

FindFunc returns the first element in the slice for which predicate returns true.

func Float32sAreSortedAsc added in v0.7.0

func Float32sAreSortedAsc(x []float32) bool

Float32sAreSortedAsc is a convenience method which calls sort.IsSorted(Float32sAsc(x)).

func Float32sAreSortedDesc added in v0.7.0

func Float32sAreSortedDesc(x []float32) bool

Float32sAreSortedDesc is a convenience method which calls sort.IsSorted(Float32sDesc(x)).

func Float64sAreSortedAsc added in v0.7.0

func Float64sAreSortedAsc(x []float64) bool

Float64sAreSortedAsc is a convenience method which calls sort.IsSorted(Float64sAsc(x)).

func Float64sAreSortedDesc added in v0.7.0

func Float64sAreSortedDesc(x []float64) bool

Float64sAreSortedDesc is a convenience method which calls sort.IsSorted(Float64sDesc(x)).

func Go

func Go(f func())

Go calls the given function with panic recover, in case of panic happens, the panic message, location and the calling stack will be logged using the default logger configured by `ConfigLog` in this package.

func Go1

func Go1(f func() error)

Go1 calls the given function with panic recover, in case an error is returned, or panic happens, the error message or panic information will be logged using the default logger configured by `ConfigLog` in this package.

func IdentifyPanic

func IdentifyPanic() string

IdentifyPanic reports the panic location when a panic happens.

func InInt32s

func InInt32s(slice []int32, elem int32) bool

InInt32s tells whether the int32 value elem is in the slice.

func InInt64s

func InInt64s(slice []int64, elem int64) bool

InInt64s tells whether the int64 value elem is in the slice.

func InSliceFunc added in v0.7.0

func InSliceFunc(slice interface{}, predicate func(i int) bool) bool

InSliceFunc iterates the given slice, it calls predicate(i) for i in range [0, n) where n is the length of the slice. When predicate(i) returns true, it stops and returns true.

The parameter predicate must be not nil, otherwise it panics.

func InSortedFloat32s added in v0.7.0

func InSortedFloat32s(slice []float32, elem float32) bool

InSortedFloat32s tells whether elem is in a sorted float32 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedFloat64s added in v0.7.0

func InSortedFloat64s(slice []float64, elem float64) bool

InSortedFloat64s tells whether elem is in a sorted float64 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedInt16s added in v0.7.0

func InSortedInt16s(slice []int16, elem int16) bool

InSortedInt16s tells whether elem is in a sorted int16 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedInt32s

func InSortedInt32s(slice []int32, elem int32) bool

InSortedInt32s tells whether elem is in a sorted int32 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedInt64s

func InSortedInt64s(slice []int64, elem int64) bool

InSortedInt64s tells whether elem is in a sorted int64 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedInt8s added in v0.7.0

func InSortedInt8s(slice []int8, elem int8) bool

InSortedInt8s tells whether elem is in a sorted int8 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedInts

func InSortedInts(slice []int, elem int) bool

InSortedInts tells whether elem is in a sorted int slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedStrings

func InSortedStrings(slice []string, elem string) bool

InSortedStrings tells whether elem is in a sorted string slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUint16s added in v0.7.0

func InSortedUint16s(slice []uint16, elem uint16) bool

InSortedUint16s tells whether elem is in a sorted uint16 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUint32s added in v0.7.0

func InSortedUint32s(slice []uint32, elem uint32) bool

InSortedUint32s tells whether elem is in a sorted uint32 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUint64s added in v0.7.0

func InSortedUint64s(slice []uint64, elem uint64) bool

InSortedUint64s tells whether elem is in a sorted uint64 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUint8s added in v0.7.0

func InSortedUint8s(slice []uint8, elem uint8) bool

InSortedUint8s tells whether elem is in a sorted uint8 slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUintptrs added in v0.7.0

func InSortedUintptrs(slice []uintptr, elem uintptr) bool

InSortedUintptrs tells whether elem is in a sorted uintptr slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InSortedUints added in v0.7.0

func InSortedUints(slice []uint, elem uint) bool

InSortedUints tells whether elem is in a sorted uint slice. The given slice must be sorted in either ascending order or descending, else it may give incorrect result.

func InStrings

func InStrings(slice []string, elem string) bool

InStrings tells whether the string value elem is in the slice.

func IndexFunc added in v0.7.0

func IndexFunc(slice interface{}, predicate func(i int) bool) int

IndexFunc iterates the given slice, it calls predicate(i) for i in range [0, n) where n is the length of the slice. When predicate(i) returns true, it stops and returns the index i.

The parameter predicate must not be nil, otherwise it panics.

func IndexInt32s

func IndexInt32s(slice []int32, elem int32) int

IndexInt32s returns the index of the first instance of elem slice, or -1 if elem is not present in slice.

func IndexInt64s

func IndexInt64s(slice []int64, elem int64) int

IndexInt64s returns the index of the first instance of elem in slice, or -1 if elem is not present in slice.

func IndexStrings

func IndexStrings(slice []string, elem string) int

IndexStrings returns the index of the first instance of elem in slice, or -1 if elem is not present in slice.

func InsertInt32s

func InsertInt32s(slice []int32, index int, elem int32) (out []int32)

InsertInt32s inserts the given int32 elem into the slice at index position. If index is equal or greater than the length of slice, the elem will be appended to the end of the slice. In case the slice is full of it's capacity, a new slice will be created and returned.

func InsertInt64s

func InsertInt64s(slice []int64, index int, elem int64) (out []int64)

InsertInt64s inserts the given int64 elem into the slice at index position. If index is equal or greater than the length of slice, the elem will be appended to the end of the slice. In case the slice is full of it's capacity, a new slice will be created and returned.

func InsertStrings

func InsertStrings(slice []string, index int, elem string) (out []string)

InsertStrings inserts the given string elem into the slice at index position. If index is equal or greater than the length of slice, the elem will be appended to the end of the slice. In case the slice is full of it's capacity, a new slice will be created and returned.

func Int16sAreSortedAsc added in v0.7.0

func Int16sAreSortedAsc(x []int16) bool

Int16sAreSortedAsc is a convenience method which calls sort.IsSorted(Int16sAsc(x)).

func Int16sAreSortedDesc added in v0.7.0

func Int16sAreSortedDesc(x []int16) bool

Int16sAreSortedDesc is a convenience method which calls sort.IsSorted(Int16sDesc(x)).

func Int32sAreSortedAsc added in v0.7.0

func Int32sAreSortedAsc(x []int32) bool

Int32sAreSortedAsc is a convenience method which calls sort.IsSorted(Int32sAsc(x)).

func Int32sAreSortedDesc added in v0.7.0

func Int32sAreSortedDesc(x []int32) bool

Int32sAreSortedDesc is a convenience method which calls sort.IsSorted(Int32sDesc(x)).

func Int64sAreSortedAsc added in v0.7.0

func Int64sAreSortedAsc(x []int64) bool

Int64sAreSortedAsc is a convenience method which calls sort.IsSorted(Int64sAsc(x)).

func Int64sAreSortedDesc added in v0.7.0

func Int64sAreSortedDesc(x []int64) bool

Int64sAreSortedDesc is a convenience method which calls sort.IsSorted(Int64sDesc(x)).

func Int8sAreSortedAsc added in v0.7.0

func Int8sAreSortedAsc(x []int8) bool

Int8sAreSortedAsc is a convenience method which calls sort.IsSorted(Int8sAsc(x)).

func Int8sAreSortedDesc added in v0.7.0

func Int8sAreSortedDesc(x []int8) bool

Int8sAreSortedDesc is a convenience method which calls sort.IsSorted(Int8sDesc(x)).

func IntsAreSortedAsc added in v0.7.0

func IntsAreSortedAsc(x []int) bool

IntsAreSortedAsc is a convenience method which calls sort.IsSorted(IntsAsc(x)).

func IntsAreSortedDesc added in v0.7.0

func IntsAreSortedDesc(x []int) bool

IntsAreSortedDesc is a convenience method which calls sort.IsSorted(IntsDesc(x)).

func IsJSONType

func IsJSONType(contentType string) bool

IsJSONType method is to check JSON content type or not.

func IsXMLType

func IsXMLType(contentType string) bool

IsXMLType method is to check XML content type or not.

func JSON

func JSON(v interface{}) string

JSON converts given object to a json string, it never returns error. The marshalling method used here does not escape HTML characters, and map keys are sorted, which helps human reading.

func JSONToReader

func JSONToReader(obj interface{}) (io.Reader, error)

JSONToReader converts an json encodeable object to an io.Reader. If obj cannot be marshaled as JSON, it reports the error.

func JoinInt64s

func JoinInt64s(slice []int64, sep string) string

JoinInt64s returns a string consisting of slice elements separated by sep.

func LastIndexFunc added in v0.7.0

func LastIndexFunc(slice interface{}, predicate func(i int) bool) int

LastIndexFunc iterates the given slice, it calls predicate(i) for i in range [0, n) in descending order, where n is the length of the slice. When predicate(i) returns true, it stops and returns the index i.

The parameter predicate must not be nil, otherwise it panics.

func LastIndexInt32s

func LastIndexInt32s(slice []int32, elem int32) int

LastIndexInt32s returns the index of the last instance of elem in slice, or -1 if elem is not present in slice.

func LastIndexInt64s

func LastIndexInt64s(slice []int64, elem int64) int

LastIndexInt64s returns the index of the last instance of elem in slice, or -1 if elem is not present in slice.

func LastIndexStrings

func LastIndexStrings(slice []string, elem string) int

LastIndexStrings returns the index of the last instance of elem in slice, or -1 if elem is not present in slice.

func Logfmt added in v0.2.11

func Logfmt(v interface{}) string

Logfmt converts given object to a string in logfmt format, it never returns error. Note that only struct and map of basic types are supported, non-basic types are simply ignored.

func MatchGroups added in v0.6.0

func MatchGroups(re *regexp.Regexp, str []byte) map[string][]byte

MatchGroups returns the matched named capturing groups. A returned value of nil indicates no match.

func MatchStringGroups added in v0.6.0

func MatchStringGroups(re *regexp.Regexp, str string) map[string]string

MatchStringGroups returns the matched named capturing groups. A returned value of nil indicates no match.

func PRETTY added in v0.9.0

func PRETTY(args ...interface{})

PRETTY is similar to DEBUG, but it calls Pretty to format non-basic-type data.

func PRETTYSkip added in v0.9.0

func PRETTYSkip(skip int, args ...interface{})

PRETTYSkip is similar to PRETTY, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".

func PanicOnError

func PanicOnError(args ...interface{})

PanicOnError fires a panic if any of the args is non-nil error.

func ParseHTMLTemplates added in v0.5.1

func ParseHTMLTemplates(rootDir string, rePattern string, funcMap htmltemplate.FuncMap) (*htmltemplate.Template, error)

ParseHTMLTemplates parses files under `rootDir` which matches the regular expression `rePattern`. Optionally a `funcMap` can be specified to use with the parsed templates.

The returned Template holds the parsed templates under the root directory, template can be retrieved using Template.Lookup(name), where name is the file path relative to rootDir, without leading "./".

func ParseInt64s

func ParseInt64s(values, sep string, ignoreZero bool) (slice []int64, malformed bool)

ParseInt64s parses a number string separated by sep into a []int64 slice. If there is invalid number value, it reports malformed = true as the second return value.

func ParseTextTemplates added in v0.5.1

func ParseTextTemplates(rootDir string, rePattern string, funcMap texttemplate.FuncMap) (*texttemplate.Template, error)

ParseTextTemplates parses files under `rootDir` which matches the regular expression `rePattern`. Optionally a `funcMap` can be specified to use with the parsed templates.

The returned Template holds the parsed templates under the root directory, template can be retrieved using Template.Lookup(name), where name is the file path relative to rootDir, without leading "./".

func Pretty

func Pretty(v interface{}) string

Pretty converts given object to a pretty formatted json string. If the input is a json string, it will be formatted using json.Indent with four space characters as indent.

func Pretty2 added in v0.14.2

func Pretty2(v interface{}) string

Pretty2 is like Pretty, but it uses two space characters as indent, instead of four.

func Recover added in v0.2.10

func Recover(ctx context.Context, err *error)

Recover recovers unexpected panic, and log error messages using logger associated with the given context, if `err` is not nil, an wrapped `PanicError` will be assigned to it.

Note that this function should not be wrapped be another function, instead it should be called directly by the `defer` statement, or it won't work as you may expect.

func ReverseInt32s

func ReverseInt32s(slice []int32, inplace bool) []int32

ReverseInt32s returns a new slice of the elements in reversed order.

When inplace is true, the slice is reversed in place, it does not create a new slice, but returns the original slice with reversed order.

func ReverseInt64s

func ReverseInt64s(slice []int64, inplace bool) []int64

ReverseInt64s returns a new slice of the elements in reversed order.

When inplace is true, the slice is reversed in place, it does not create a new slice, but returns the original slice with reversed order.

func ReverseSlice

func ReverseSlice(slice interface{}, inplace bool) interface{}

ReverseSlice returns a new slice containing the elements of the given slice in reversed order.

When inplace is true, the slice is reversed in place, it does not create a new slice, but returns the original slice with reversed order.

The given slice must be not nil, otherwise it panics.

func ReverseStrings

func ReverseStrings(slice []string, inplace bool) []string

ReverseStrings returns a new slice of the elements in reversed order.

When inplace is true, the slice is reversed in place, it does not create a new slice, but returns the original slice with reversed order.

func SPEW

func SPEW(args ...interface{})

SPEW is similar to DEBUG, but it calls spew.Sprintf to format non-basic-type data.

func SPEWSkip added in v0.9.0

func SPEWSkip(skip int, args ...interface{})

SPEWSkip is similar to SPEW, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".

func Safe

func Safe(f func()) func() error

Safe returns an wrapped function with panic recover.

Note that if panic happens, the wrapped function does not log messages, instead it will be returned as a `*PanicError`, the caller take responsibility to log the panic messages.

func Safe1

func Safe1(f func() error) func() error

Safe1 returns an wrapped function with panic recover.

Note that if panic or error happens, the wrapped function does not log messages, instead it will be returned as an error, the caller take responsibility to log the panic or error messages.

func SetDefault added in v0.2.11

func SetDefault(dst interface{}, value ...interface{})

SetDefault checks whether dst points to a zero value, if yes, it sets the first non-zero value to dst. dst must be a pointer to same type as value, else it panics.

func SingleJoin

func SingleJoin(sep string, text ...string) string

SingleJoin joins the given text segments using sep. No matter whether a segment begins or ends with sep or not, it guarantees that only one sep appears between two segments.

func SlashJoin

func SlashJoin(path ...string) string

SlashJoin joins the given path segments using "/". No matter whether a segment begins or ends with "/" or not, it guarantees that only one "/" appears between two segments.

func SortFloat32sAsc added in v0.7.0

func SortFloat32sAsc(x []float32)

SortFloat32sAsc is a convenience method which calls sort.Sort(Float32sAsc(x)).

func SortFloat32sDesc added in v0.7.0

func SortFloat32sDesc(x []float32)

SortFloat32sDesc is a convenience method which calls sort.Sort(Float32sDesc(x)).

func SortFloat64sAsc added in v0.7.0

func SortFloat64sAsc(x []float64)

SortFloat64sAsc is a convenience method which calls sort.Sort(Float64sAsc(x)).

func SortFloat64sDesc added in v0.7.0

func SortFloat64sDesc(x []float64)

SortFloat64sDesc is a convenience method which calls sort.Sort(Float64sDesc(x)).

func SortInt16sAsc added in v0.7.0

func SortInt16sAsc(x []int16)

SortInt16sAsc is a convenience method which calls sort.Sort(Int16sAsc(x)).

func SortInt16sDesc added in v0.7.0

func SortInt16sDesc(x []int16)

SortInt16sDesc is a convenience method which calls sort.Sort(Int16sDesc(x)).

func SortInt32sAsc added in v0.7.0

func SortInt32sAsc(x []int32)

SortInt32sAsc is a convenience method which calls sort.Sort(Int32sAsc(x)).

func SortInt32sDesc added in v0.7.0

func SortInt32sDesc(x []int32)

SortInt32sDesc is a convenience method which calls sort.Sort(Int32sDesc(x)).

func SortInt64sAsc added in v0.7.0

func SortInt64sAsc(x []int64)

SortInt64sAsc is a convenience method which calls sort.Sort(Int64sAsc(x)).

func SortInt64sDesc added in v0.7.0

func SortInt64sDesc(x []int64)

SortInt64sDesc is a convenience method which calls sort.Sort(Int64sDesc(x)).

func SortInt8sAsc added in v0.7.0

func SortInt8sAsc(x []int8)

SortInt8sAsc is a convenience method which calls sort.Sort(Int8sAsc(x)).

func SortInt8sDesc added in v0.7.0

func SortInt8sDesc(x []int8)

SortInt8sDesc is a convenience method which calls sort.Sort(Int8sDesc(x)).

func SortIntsAsc added in v0.7.0

func SortIntsAsc(x []int)

SortIntsAsc is a convenience method which calls sort.Sort(IntsAsc(x)).

func SortIntsDesc added in v0.7.0

func SortIntsDesc(x []int)

SortIntsDesc is a convenience method which calls sort.Sort(IntsDesc(x)).

func SortStringsAsc added in v0.7.0

func SortStringsAsc(x []string)

SortStringsAsc is a convenience method which calls sort.Sort(StringsAsc(x)).

func SortStringsDesc added in v0.7.0

func SortStringsDesc(x []string)

SortStringsDesc is a convenience method which calls sort.Sort(StringsDesc(x)).

func SortUint16sAsc added in v0.7.0

func SortUint16sAsc(x []uint16)

SortUint16sAsc is a convenience method which calls sort.Sort(Uint16sAsc(x)).

func SortUint16sDesc added in v0.7.0

func SortUint16sDesc(x []uint16)

SortUint16sDesc is a convenience method which calls sort.Sort(Uint16sDesc(x)).

func SortUint32sAsc added in v0.7.0

func SortUint32sAsc(x []uint32)

SortUint32sAsc is a convenience method which calls sort.Sort(Uint32sAsc(x)).

func SortUint32sDesc added in v0.7.0

func SortUint32sDesc(x []uint32)

SortUint32sDesc is a convenience method which calls sort.Sort(Uint32sDesc(x)).

func SortUint64sAsc added in v0.7.0

func SortUint64sAsc(x []uint64)

SortUint64sAsc is a convenience method which calls sort.Sort(Uint64sAsc(x)).

func SortUint64sDesc added in v0.7.0

func SortUint64sDesc(x []uint64)

SortUint64sDesc is a convenience method which calls sort.Sort(Uint64sDesc(x)).

func SortUint8sAsc added in v0.7.0

func SortUint8sAsc(x []uint8)

SortUint8sAsc is a convenience method which calls sort.Sort(Uint8sAsc(x)).

func SortUint8sDesc added in v0.7.0

func SortUint8sDesc(x []uint8)

SortUint8sDesc is a convenience method which calls sort.Sort(Uint8sDesc(x)).

func SortUintptrsAsc added in v0.7.0

func SortUintptrsAsc(x []uintptr)

SortUintptrsAsc is a convenience method which calls sort.Sort(UintptrsAsc(x)).

func SortUintptrsDesc added in v0.7.0

func SortUintptrsDesc(x []uintptr)

SortUintptrsDesc is a convenience method which calls sort.Sort(UintptrsDesc(x)).

func SortUintsAsc added in v0.7.0

func SortUintsAsc(x []uint)

SortUintsAsc is a convenience method which calls sort.Sort(UintsAsc(x)).

func SortUintsDesc added in v0.7.0

func SortUintsDesc(x []uint)

SortUintsDesc is a convenience method which calls sort.Sort(UintsDesc(x)).

func SplitInt32s added in v0.9.0

func SplitInt32s(slice []int32, batch int) [][]int32

SplitInt32s splits a large int32 slice to batches.

func SplitInt64s added in v0.9.0

func SplitInt64s(slice []int64, batch int) [][]int64

SplitInt64s splits a large int64 slice to batches.

func SplitSlice added in v0.2.10

func SplitSlice(slice interface{}, batch int) interface{}

SplitSlice splits a large slice []T to batches, it returns a slice of slice of type [][]T.

The given slice must not be nil, otherwise it panics.

func SplitStrings added in v0.9.0

func SplitStrings(slice []string, batch int) [][]string

SplitStrings splits a large string slice to batches.

func StringsAreSortedAsc added in v0.7.0

func StringsAreSortedAsc(x []string) bool

StringsAreSortedAsc is a convenience method which calls sort.IsSorted(StringsAsc(x)).

func StringsAreSortedDesc added in v0.7.0

func StringsAreSortedDesc(x []string) bool

StringsAreSortedDesc is a convenience method which calls sort.IsSorted(StringsDesc(x)).

func SumSlice added in v0.2.10

func SumSlice(slice interface{}) int64

SumSlice returns the sum value of the elements in the given slice. If slice is nil or it's elements are not integers, it panics.

func ToInterfaceSlice added in v0.7.0

func ToInterfaceSlice(slice interface{}) []interface{}

ToInterfaceSlice returns a []interface{} containing elements from slice.

func ToMap

func ToMap(slice interface{}, keyField string) interface{}

ToMap converts the given slice of struct (or pointer to struct) to a map, with the field specified by keyField as key and the slice element as value.

If slice is nil, keyField does not exists or the element of slice is not struct or pointer to struct, it panics.

func ToMapMap

func ToMapMap(slice interface{}, keyField, subKeyField string) interface{}

ToMapMap converts the given slice of struct (or pointer to struct) to a map, with the field specified by keyField as key. The returned map's value is another map with the field specified by subKeyField as key and thee slice element as value.

If slice is nil, keyField or subKeyField does not exists or the element of slice is not struct or pointer to struct, it panics.

func ToSliceMap

func ToSliceMap(slice interface{}, keyField string) interface{}

ToSliceMap converts the given slice of struct (or pointer to struct) to a map, with the field specified by keyField as key and a slice of elements which have same key as value.

If slice is nil, keyField does not exists or the element of slice is not struct or pointer to struct, it panics.

func Uint16sAreSortedAsc added in v0.7.0

func Uint16sAreSortedAsc(x []uint16) bool

Uint16sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint16sAsc(x)).

func Uint16sAreSortedDesc added in v0.7.0

func Uint16sAreSortedDesc(x []uint16) bool

Uint16sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint16sDesc(x)).

func Uint32sAreSortedAsc added in v0.7.0

func Uint32sAreSortedAsc(x []uint32) bool

Uint32sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint32sAsc(x)).

func Uint32sAreSortedDesc added in v0.7.0

func Uint32sAreSortedDesc(x []uint32) bool

Uint32sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint32sDesc(x)).

func Uint64sAreSortedAsc added in v0.7.0

func Uint64sAreSortedAsc(x []uint64) bool

Uint64sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint64sAsc(x)).

func Uint64sAreSortedDesc added in v0.7.0

func Uint64sAreSortedDesc(x []uint64) bool

Uint64sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint64sDesc(x)).

func Uint8sAreSortedAsc added in v0.7.0

func Uint8sAreSortedAsc(x []uint8) bool

Uint8sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint8sAsc(x)).

func Uint8sAreSortedDesc added in v0.7.0

func Uint8sAreSortedDesc(x []uint8) bool

Uint8sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint8sDesc(x)).

func UintptrsAreSortedAsc added in v0.7.0

func UintptrsAreSortedAsc(x []uintptr) bool

UintptrsAreSortedAsc is a convenience method which calls sort.IsSorted(UintptrsAsc(x)).

func UintptrsAreSortedDesc added in v0.7.0

func UintptrsAreSortedDesc(x []uintptr) bool

UintptrsAreSortedDesc is a convenience method which calls sort.IsSorted(UintptrsDesc(x)).

func UintsAreSortedAsc added in v0.7.0

func UintsAreSortedAsc(x []uint) bool

UintsAreSortedAsc is a convenience method which calls sort.IsSorted(UintsAsc(x)).

func UintsAreSortedDesc added in v0.7.0

func UintsAreSortedDesc(x []uint) bool

UintsAreSortedDesc is a convenience method which calls sort.IsSorted(UintsDesc(x)).

func UniqueInt32s

func UniqueInt32s(slice []int32, inplace bool) []int32

UniqueInt32s returns a new slice containing the elements of the given slice in same order, but filter out duplicate values.

When inplace is true, it does not create a new slice, the unique values will be written to the input slice from the beginning.

func UniqueInt64s

func UniqueInt64s(slice []int64, inplace bool) []int64

UniqueInt64s returns a new slice containing the elements of the given slice in same order, but filter out duplicate values.

When inplace is true, it does not create a new slice, the unique values will be written to the input slice from the beginning.

func UniqueStrings

func UniqueStrings(slice []string, inplace bool) []string

UniqueStrings returns a new slice containing the elements of the given slice in same order, but filter out duplicate values.

When inplace is true, it does not create a new slice, the unique values will be written to the input slice from the beginning.

func XMLToReader

func XMLToReader(obj interface{}) (io.Reader, error)

XMLToReader converts an XML encodeable object to an io.Reader. If obj cannot be marshaled as XML, it reports the error.

Types

type DebugLogger

type DebugLogger interface {
	Debugf(format string, args ...interface{})
}

DebugLogger is an interface which log an message at DEBUG level. It's implemented by *logrus.Logger, *logrus.Entry, *zap.SugaredLogger, and many other logging packages.

type ErrDebugLogger added in v0.2.10

type ErrDebugLogger interface {
	ErrLogger
	DebugLogger
}

ErrDebugLogger is an interface which log messages at ERROR and DEBUG level. It's implemented by *logrus.Logger, *logrus.Entry, *zap.SugaredLogger, and many other logging packages.

type ErrLogger

type ErrLogger interface {
	Errorf(format string, args ...interface{})
}

ErrLogger is an interface which log an message at ERROR level. It's implemented by *logrus.Logger, *logrus.Entry, *zap.SugaredLogger, and many other logging packages.

type Float32sAsc added in v0.7.0

type Float32sAsc []float32

Float32sAsc attaches the methods of sort.Interface to []float32, sorting in ascending order.

func (Float32sAsc) Len added in v0.7.0

func (x Float32sAsc) Len() int

func (Float32sAsc) Less added in v0.7.0

func (x Float32sAsc) Less(i, j int) bool

func (Float32sAsc) Sort added in v0.7.0

func (x Float32sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Float32sAsc) Swap added in v0.7.0

func (x Float32sAsc) Swap(i, j int)

type Float32sDesc added in v0.7.0

type Float32sDesc []float32

Float32sDesc attaches the methods of sort.Interface to []float32, sorting in descending order.

func (Float32sDesc) Len added in v0.7.0

func (x Float32sDesc) Len() int

func (Float32sDesc) Less added in v0.7.0

func (x Float32sDesc) Less(i, j int) bool

func (Float32sDesc) Sort added in v0.7.0

func (x Float32sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Float32sDesc) Swap added in v0.7.0

func (x Float32sDesc) Swap(i, j int)

type Float64sAsc added in v0.7.0

type Float64sAsc []float64

Float64sAsc attaches the methods of sort.Interface to []float64, sorting in ascending order.

func (Float64sAsc) Len added in v0.7.0

func (x Float64sAsc) Len() int

func (Float64sAsc) Less added in v0.7.0

func (x Float64sAsc) Less(i, j int) bool

func (Float64sAsc) Sort added in v0.7.0

func (x Float64sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Float64sAsc) Swap added in v0.7.0

func (x Float64sAsc) Swap(i, j int)

type Float64sDesc added in v0.7.0

type Float64sDesc []float64

Float64sDesc attaches the methods of sort.Interface to []float64, sorting in descending order.

func (Float64sDesc) Len added in v0.7.0

func (x Float64sDesc) Len() int

func (Float64sDesc) Less added in v0.7.0

func (x Float64sDesc) Less(i, j int) bool

func (Float64sDesc) Sort added in v0.7.0

func (x Float64sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Float64sDesc) Swap added in v0.7.0

func (x Float64sDesc) Swap(i, j int)

type IJ

type IJ struct{ I, J int }

IJ represents a slice index of I, J.

func SplitBatch

func SplitBatch(total, batch int) []IJ

SplitBatch splits a large number to batches, it's mainly designed to help operations with large slice, such as inserting lots of records into database, or logging lots of identifiers, etc.

type Int16sAsc added in v0.7.0

type Int16sAsc []int16

Int16sAsc attaches the methods of sort.Interface to []int16, sorting in ascending order.

func (Int16sAsc) Len added in v0.7.0

func (x Int16sAsc) Len() int

func (Int16sAsc) Less added in v0.7.0

func (x Int16sAsc) Less(i, j int) bool

func (Int16sAsc) Sort added in v0.7.0

func (x Int16sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int16sAsc) Swap added in v0.7.0

func (x Int16sAsc) Swap(i, j int)

type Int16sDesc added in v0.7.0

type Int16sDesc []int16

Int16sDesc attaches the methods of sort.Interface to []int16, sorting in descending order.

func (Int16sDesc) Len added in v0.7.0

func (x Int16sDesc) Len() int

func (Int16sDesc) Less added in v0.7.0

func (x Int16sDesc) Less(i, j int) bool

func (Int16sDesc) Sort added in v0.7.0

func (x Int16sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int16sDesc) Swap added in v0.7.0

func (x Int16sDesc) Swap(i, j int)

type Int32sAsc added in v0.7.0

type Int32sAsc []int32

Int32sAsc attaches the methods of sort.Interface to []int32, sorting in ascending order.

func (Int32sAsc) Len added in v0.7.0

func (x Int32sAsc) Len() int

func (Int32sAsc) Less added in v0.7.0

func (x Int32sAsc) Less(i, j int) bool

func (Int32sAsc) Sort added in v0.7.0

func (x Int32sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int32sAsc) Swap added in v0.7.0

func (x Int32sAsc) Swap(i, j int)

type Int32sDesc added in v0.7.0

type Int32sDesc []int32

Int32sDesc attaches the methods of sort.Interface to []int32, sorting in descending order.

func (Int32sDesc) Len added in v0.7.0

func (x Int32sDesc) Len() int

func (Int32sDesc) Less added in v0.7.0

func (x Int32sDesc) Less(i, j int) bool

func (Int32sDesc) Sort added in v0.7.0

func (x Int32sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int32sDesc) Swap added in v0.7.0

func (x Int32sDesc) Swap(i, j int)

type Int64sAsc added in v0.7.0

type Int64sAsc []int64

Int64sAsc attaches the methods of sort.Interface to []int64, sorting in ascending order.

func (Int64sAsc) Len added in v0.7.0

func (x Int64sAsc) Len() int

func (Int64sAsc) Less added in v0.7.0

func (x Int64sAsc) Less(i, j int) bool

func (Int64sAsc) Sort added in v0.7.0

func (x Int64sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int64sAsc) Swap added in v0.7.0

func (x Int64sAsc) Swap(i, j int)

type Int64sDesc added in v0.7.0

type Int64sDesc []int64

Int64sDesc attaches the methods of sort.Interface to []int64, sorting in descending order.

func (Int64sDesc) Len added in v0.7.0

func (x Int64sDesc) Len() int

func (Int64sDesc) Less added in v0.7.0

func (x Int64sDesc) Less(i, j int) bool

func (Int64sDesc) Sort added in v0.7.0

func (x Int64sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int64sDesc) Swap added in v0.7.0

func (x Int64sDesc) Swap(i, j int)

type Int8sAsc added in v0.7.0

type Int8sAsc []int8

Int8sAsc attaches the methods of sort.Interface to []int8, sorting in ascending order.

func (Int8sAsc) Len added in v0.7.0

func (x Int8sAsc) Len() int

func (Int8sAsc) Less added in v0.7.0

func (x Int8sAsc) Less(i, j int) bool

func (Int8sAsc) Sort added in v0.7.0

func (x Int8sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int8sAsc) Swap added in v0.7.0

func (x Int8sAsc) Swap(i, j int)

type Int8sDesc added in v0.7.0

type Int8sDesc []int8

Int8sDesc attaches the methods of sort.Interface to []int8, sorting in descending order.

func (Int8sDesc) Len added in v0.7.0

func (x Int8sDesc) Len() int

func (Int8sDesc) Less added in v0.7.0

func (x Int8sDesc) Less(i, j int) bool

func (Int8sDesc) Sort added in v0.7.0

func (x Int8sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Int8sDesc) Swap added in v0.7.0

func (x Int8sDesc) Swap(i, j int)

type IntsAsc added in v0.7.0

type IntsAsc []int

IntsAsc attaches the methods of sort.Interface to []int, sorting in ascending order.

func (IntsAsc) Len added in v0.7.0

func (x IntsAsc) Len() int

func (IntsAsc) Less added in v0.7.0

func (x IntsAsc) Less(i, j int) bool

func (IntsAsc) Sort added in v0.7.0

func (x IntsAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (IntsAsc) Swap added in v0.7.0

func (x IntsAsc) Swap(i, j int)

type IntsDesc added in v0.7.0

type IntsDesc []int

IntsDesc attaches the methods of sort.Interface to []int, sorting in descending order.

func (IntsDesc) Len added in v0.7.0

func (x IntsDesc) Len() int

func (IntsDesc) Less added in v0.7.0

func (x IntsDesc) Less(i, j int) bool

func (IntsDesc) Sort added in v0.7.0

func (x IntsDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (IntsDesc) Swap added in v0.7.0

func (x IntsDesc) Swap(i, j int)

type LogCfg added in v0.4.0

type LogCfg struct {
	EnableDebug func() bool
	Logger      func() ErrDebugLogger
	CtxLogger   func(context.Context) ErrDebugLogger
}

type Map

type Map = gemap.Map

type PanicError

type PanicError struct {
	Exception  interface{}
	Location   string
	Stacktrace []byte
}

PanicError represents an captured panic error.

func (*PanicError) Error

func (p *PanicError) Error() string

type PrintFunc

type PrintFunc func(format string, args ...interface{})

PrintFunc is a function to print the given arguments in format to somewhere. It implements the interface `ErrDebugLogger`.

func (PrintFunc) Debugf

func (f PrintFunc) Debugf(format string, args ...interface{})

func (PrintFunc) Errorf

func (f PrintFunc) Errorf(format string, args ...interface{})

type Request

type Request struct {

	// Req should be a fully prepared http Request to sent, if not nil,
	// the following `Method`, `URL`, `Params`, `JSON`, `XML`, `Form`, `Body`
	// will be ignored.
	//
	// If Req is nil, it will be filled using the following data `Method`,
	// `URL`, `Params`, `JSON`, `XML`, `Form`, `Body` to construct the `http.Request`.
	//
	// When building http body, the priority is JSON > XML > Form > Body.
	Req *http.Request

	// Method specifies the verb for the http request, it's optional,
	// default is "GET".
	Method string

	// URL specifies the url to make the http request.
	// It's required if Req is nil.
	URL string

	// Params specifies optional params to merge with URL, it must be one of
	// the following types:
	// - map[string]string
	// - map[string][]string
	// - map[string]interface{}
	// - url.Values
	Params interface{}

	// JSON specifies optional body data for request which can take body,
	// the content-type will be "application/json", it must be one of
	// the following types:
	// - io.Reader
	// - []byte (will be wrapped with bytes.NewReader)
	// - string (will be wrapped with strings.NewReader)
	// - interface{} (will be marshaled with json.Marshal)
	JSON interface{}

	// XML specifies optional body data for request which can take body,
	// the content-type will be "application/xml", it must be one of
	// the following types:
	// - io.Reader
	// - []byte (will be wrapped with bytes.NewReader)
	// - string (will be wrapped with strings.NewReader)
	// - interface{} (will be marshaled with xml.Marshal)
	XML interface{}

	// Form specifies optional body data for request which can take body,
	// the content-type will be "application/x-www-form-urlencoded",
	// it must be one of the following types:
	// - io.Reader
	// - []byte (will be wrapped with bytes.NewReader)
	// - string (will be wrapped with strings.NewReader)
	// - url.Values (will be encoded and wrapped as io.Reader)
	// - map[string]string (will be converted to url.Values)
	// - map[string][]string (will be converted to url.Values)
	// - map[string]interface{} (will be converted to url.Values)
	Form interface{}

	// Body specifies optional body data for request which can take body,
	// the content-type will be detected from the content (may be incorrect),
	// it should be one of the following types:
	// - io.Reader
	// - []byte (will be wrapped with bytes.NewReader)
	// - string (will be wrapped with strings.NewReader)
	Body interface{}

	// Headers will be copied to the request before sent.
	//
	// If "Content-Type" presents, it will replace the default value
	// set by `JSON`, `XML`, `Form`, or `Body`.
	Headers map[string]string

	// Resp specifies an optional destination to unmarshal the response data.
	// if `Unmarshal` is not provided, the header "Content-Type" will be used to
	// detect XML content, else `json.Unmarshal` will be used.
	Resp interface{}

	// Unmarshal specifies an optional function to unmarshal the response data.
	Unmarshal func([]byte, interface{}) error

	// Context specifies an optional context.Context to use with http request.
	Context context.Context

	// Timeout specifies an optional timeout of the http request, if
	// timeout > 0, the request will be attached an timeout context.Context.
	// `Timeout` takes higher priority than `Context`, it both available, only
	// `Timeout` takes effect.
	Timeout time.Duration

	// Client specifies an optional http.Client to do the request, instead of
	// the default http client.
	Client *http.Client

	// DisableRedirect tells the http client don't follow response redirection.
	DisableRedirect bool

	// DumpRequest makes the http request being logged before sent.
	DumpRequest bool

	// DumpResponse makes the http response being logged after received.
	DumpResponse bool

	// RaiseForStatus tells `DoRequest` to report an error if the response
	// status code >= 400. The error will be formatted as "unexpected status: <STATUS>".
	RaiseForStatus bool
}

Request represents a request and options to send with the DoRequest function.

type SafeMap

type SafeMap = gemap.SafeMap

type StringsAsc added in v0.7.0

type StringsAsc []string

StringsAsc attaches the methods of sort.Interface to []string, sorting in ascending order.

func (StringsAsc) Len added in v0.7.0

func (x StringsAsc) Len() int

func (StringsAsc) Less added in v0.7.0

func (x StringsAsc) Less(i, j int) bool

func (StringsAsc) Sort added in v0.7.0

func (x StringsAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (StringsAsc) Swap added in v0.7.0

func (x StringsAsc) Swap(i, j int)

type StringsDesc added in v0.7.0

type StringsDesc []string

StringsDesc attaches the methods of sort.Interface to []string, sorting in descending order.

func (StringsDesc) Len added in v0.7.0

func (x StringsDesc) Len() int

func (StringsDesc) Less added in v0.7.0

func (x StringsDesc) Less(i, j int) bool

func (StringsDesc) Sort added in v0.7.0

func (x StringsDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (StringsDesc) Swap added in v0.7.0

func (x StringsDesc) Swap(i, j int)

type Uint16sAsc added in v0.7.0

type Uint16sAsc []uint16

Uint16sAsc attaches the methods of sort.Interface to []uint16, sorting in ascending order.

func (Uint16sAsc) Len added in v0.7.0

func (x Uint16sAsc) Len() int

func (Uint16sAsc) Less added in v0.7.0

func (x Uint16sAsc) Less(i, j int) bool

func (Uint16sAsc) Sort added in v0.7.0

func (x Uint16sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint16sAsc) Swap added in v0.7.0

func (x Uint16sAsc) Swap(i, j int)

type Uint16sDesc added in v0.7.0

type Uint16sDesc []uint16

Uint16sDesc attaches the methods of sort.Interface to []uint16, sorting in descending order.

func (Uint16sDesc) Len added in v0.7.0

func (x Uint16sDesc) Len() int

func (Uint16sDesc) Less added in v0.7.0

func (x Uint16sDesc) Less(i, j int) bool

func (Uint16sDesc) Sort added in v0.7.0

func (x Uint16sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint16sDesc) Swap added in v0.7.0

func (x Uint16sDesc) Swap(i, j int)

type Uint32sAsc added in v0.7.0

type Uint32sAsc []uint32

Uint32sAsc attaches the methods of sort.Interface to []uint32, sorting in ascending order.

func (Uint32sAsc) Len added in v0.7.0

func (x Uint32sAsc) Len() int

func (Uint32sAsc) Less added in v0.7.0

func (x Uint32sAsc) Less(i, j int) bool

func (Uint32sAsc) Sort added in v0.7.0

func (x Uint32sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint32sAsc) Swap added in v0.7.0

func (x Uint32sAsc) Swap(i, j int)

type Uint32sDesc added in v0.7.0

type Uint32sDesc []uint32

Uint32sDesc attaches the methods of sort.Interface to []uint32, sorting in descending order.

func (Uint32sDesc) Len added in v0.7.0

func (x Uint32sDesc) Len() int

func (Uint32sDesc) Less added in v0.7.0

func (x Uint32sDesc) Less(i, j int) bool

func (Uint32sDesc) Sort added in v0.7.0

func (x Uint32sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint32sDesc) Swap added in v0.7.0

func (x Uint32sDesc) Swap(i, j int)

type Uint64sAsc added in v0.7.0

type Uint64sAsc []uint64

Uint64sAsc attaches the methods of sort.Interface to []uint64, sorting in ascending order.

func (Uint64sAsc) Len added in v0.7.0

func (x Uint64sAsc) Len() int

func (Uint64sAsc) Less added in v0.7.0

func (x Uint64sAsc) Less(i, j int) bool

func (Uint64sAsc) Sort added in v0.7.0

func (x Uint64sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint64sAsc) Swap added in v0.7.0

func (x Uint64sAsc) Swap(i, j int)

type Uint64sDesc added in v0.7.0

type Uint64sDesc []uint64

Uint64sDesc attaches the methods of sort.Interface to []uint64, sorting in descending order.

func (Uint64sDesc) Len added in v0.7.0

func (x Uint64sDesc) Len() int

func (Uint64sDesc) Less added in v0.7.0

func (x Uint64sDesc) Less(i, j int) bool

func (Uint64sDesc) Sort added in v0.7.0

func (x Uint64sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint64sDesc) Swap added in v0.7.0

func (x Uint64sDesc) Swap(i, j int)

type Uint8sAsc added in v0.7.0

type Uint8sAsc []uint8

Uint8sAsc attaches the methods of sort.Interface to []uint8, sorting in ascending order.

func (Uint8sAsc) Len added in v0.7.0

func (x Uint8sAsc) Len() int

func (Uint8sAsc) Less added in v0.7.0

func (x Uint8sAsc) Less(i, j int) bool

func (Uint8sAsc) Sort added in v0.7.0

func (x Uint8sAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint8sAsc) Swap added in v0.7.0

func (x Uint8sAsc) Swap(i, j int)

type Uint8sDesc added in v0.7.0

type Uint8sDesc []uint8

Uint8sDesc attaches the methods of sort.Interface to []uint8, sorting in descending order.

func (Uint8sDesc) Len added in v0.7.0

func (x Uint8sDesc) Len() int

func (Uint8sDesc) Less added in v0.7.0

func (x Uint8sDesc) Less(i, j int) bool

func (Uint8sDesc) Sort added in v0.7.0

func (x Uint8sDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (Uint8sDesc) Swap added in v0.7.0

func (x Uint8sDesc) Swap(i, j int)

type UintptrsAsc added in v0.7.0

type UintptrsAsc []uintptr

UintptrsAsc attaches the methods of sort.Interface to []uintptr, sorting in ascending order.

func (UintptrsAsc) Len added in v0.7.0

func (x UintptrsAsc) Len() int

func (UintptrsAsc) Less added in v0.7.0

func (x UintptrsAsc) Less(i, j int) bool

func (UintptrsAsc) Sort added in v0.7.0

func (x UintptrsAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (UintptrsAsc) Swap added in v0.7.0

func (x UintptrsAsc) Swap(i, j int)

type UintptrsDesc added in v0.7.0

type UintptrsDesc []uintptr

UintptrsDesc attaches the methods of sort.Interface to []uintptr, sorting in descending order.

func (UintptrsDesc) Len added in v0.7.0

func (x UintptrsDesc) Len() int

func (UintptrsDesc) Less added in v0.7.0

func (x UintptrsDesc) Less(i, j int) bool

func (UintptrsDesc) Sort added in v0.7.0

func (x UintptrsDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (UintptrsDesc) Swap added in v0.7.0

func (x UintptrsDesc) Swap(i, j int)

type UintsAsc added in v0.7.0

type UintsAsc []uint

UintsAsc attaches the methods of sort.Interface to []uint, sorting in ascending order.

func (UintsAsc) Len added in v0.7.0

func (x UintsAsc) Len() int

func (UintsAsc) Less added in v0.7.0

func (x UintsAsc) Less(i, j int) bool

func (UintsAsc) Sort added in v0.7.0

func (x UintsAsc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (UintsAsc) Swap added in v0.7.0

func (x UintsAsc) Swap(i, j int)

type UintsDesc added in v0.7.0

type UintsDesc []uint

UintsDesc attaches the methods of sort.Interface to []uint, sorting in descending order.

func (UintsDesc) Len added in v0.7.0

func (x UintsDesc) Len() int

func (UintsDesc) Less added in v0.7.0

func (x UintsDesc) Less(i, j int) bool

func (UintsDesc) Sort added in v0.7.0

func (x UintsDesc) Sort()

Sort is a convenience method which calls sort.Sort(x).

func (UintsDesc) Swap added in v0.7.0

func (x UintsDesc) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL