Documentation ¶
Index ¶
- Variables
- func Caller(skip int) (name, file string, line int)
- func ConfigLog(cfg LogCfg)
- func CopyStdLog(f func()) []byte
- func CopyStdout(f func()) ([]byte, error)
- func DEBUG(args ...interface{})
- func DEBUGSkip(skip int, args ...interface{})
- func DUMP(args ...interface{})
- func DUMPSkip(skip int, args ...interface{})
- func DecodeJSON(r io.Reader, v interface{}) error
- func DecodeXML(r io.Reader, v interface{}) error
- func DiffInt32s(a []int32, b []int32) []int32
- func DiffInt64s(a []int64, b []int64) []int64
- func DiffStrings(a []string, b []string) []string
- func DoRequest(req *Request) (respContent []byte, status int, err error)
- func EnsureError(v interface{}) error
- func FilterFunc(slice interface{}, predicate func(i int) bool) interface{}
- func FilterInt32s(slice []int32, predicate func(i int) bool) []int32
- func FilterInt64s(slice []int64, predicate func(i int) bool) []int64
- func FilterStrings(slice []string, predicate func(i int) bool) []string
- func FindFunc(slice interface{}, predicate func(i int) bool) interface{}
- func Float32sAreSortedAsc(x []float32) bool
- func Float32sAreSortedDesc(x []float32) bool
- func Float64sAreSortedAsc(x []float64) bool
- func Float64sAreSortedDesc(x []float64) bool
- func Go(f func())
- func Go1(f func() error)
- func IdentifyPanic() string
- func InInt32s(slice []int32, elem int32) bool
- func InInt64s(slice []int64, elem int64) bool
- func InSliceFunc(slice interface{}, predicate func(i int) bool) bool
- func InSortedFloat32s(slice []float32, elem float32) bool
- func InSortedFloat64s(slice []float64, elem float64) bool
- func InSortedInt16s(slice []int16, elem int16) bool
- func InSortedInt32s(slice []int32, elem int32) bool
- func InSortedInt64s(slice []int64, elem int64) bool
- func InSortedInt8s(slice []int8, elem int8) bool
- func InSortedInts(slice []int, elem int) bool
- func InSortedStrings(slice []string, elem string) bool
- func InSortedUint16s(slice []uint16, elem uint16) bool
- func InSortedUint32s(slice []uint32, elem uint32) bool
- func InSortedUint64s(slice []uint64, elem uint64) bool
- func InSortedUint8s(slice []uint8, elem uint8) bool
- func InSortedUintptrs(slice []uintptr, elem uintptr) bool
- func InSortedUints(slice []uint, elem uint) bool
- func InStrings(slice []string, elem string) bool
- func IndexFunc(slice interface{}, predicate func(i int) bool) int
- func IndexInt32s(slice []int32, elem int32) int
- func IndexInt64s(slice []int64, elem int64) int
- func IndexStrings(slice []string, elem string) int
- func InsertInt32s(slice []int32, index int, elem int32) (out []int32)
- func InsertInt64s(slice []int64, index int, elem int64) (out []int64)
- func InsertStrings(slice []string, index int, elem string) (out []string)
- func Int16sAreSortedAsc(x []int16) bool
- func Int16sAreSortedDesc(x []int16) bool
- func Int32sAreSortedAsc(x []int32) bool
- func Int32sAreSortedDesc(x []int32) bool
- func Int64sAreSortedAsc(x []int64) bool
- func Int64sAreSortedDesc(x []int64) bool
- func Int8sAreSortedAsc(x []int8) bool
- func Int8sAreSortedDesc(x []int8) bool
- func IntsAreSortedAsc(x []int) bool
- func IntsAreSortedDesc(x []int) bool
- func IsJSONType(contentType string) bool
- func IsXMLType(contentType string) bool
- func JSON(v interface{}) string
- func JSONToReader(obj interface{}) (io.Reader, error)
- func JoinInt64s(slice []int64, sep string) string
- func LastIndexFunc(slice interface{}, predicate func(i int) bool) int
- func LastIndexInt32s(slice []int32, elem int32) int
- func LastIndexInt64s(slice []int64, elem int64) int
- func LastIndexStrings(slice []string, elem string) int
- func Logfmt(v interface{}) string
- func MatchGroups(re *regexp.Regexp, str []byte) map[string][]byte
- func MatchStringGroups(re *regexp.Regexp, str string) map[string]string
- func PRETTY(args ...interface{})
- func PRETTYSkip(skip int, args ...interface{})
- func PanicOnError(args ...interface{})
- func ParseHTMLTemplates(rootDir string, rePattern string, funcMap htmltemplate.FuncMap) (*htmltemplate.Template, error)
- func ParseInt64s(values, sep string, ignoreZero bool) (slice []int64, malformed bool)
- func ParseTextTemplates(rootDir string, rePattern string, funcMap texttemplate.FuncMap) (*texttemplate.Template, error)
- func Pretty(v interface{}) string
- func Pretty2(v interface{}) string
- func Recover(ctx context.Context, err *error)
- func ReverseInt32s(slice []int32, inplace bool) []int32
- func ReverseInt64s(slice []int64, inplace bool) []int64
- func ReverseSlice(slice interface{}, inplace bool) interface{}
- func ReverseStrings(slice []string, inplace bool) []string
- func SPEW(args ...interface{})
- func SPEWSkip(skip int, args ...interface{})
- func Safe(f func()) func() error
- func Safe1(f func() error) func() error
- func SetDefault(dst interface{}, value ...interface{})
- func SingleJoin(sep string, text ...string) string
- func SlashJoin(path ...string) string
- func SortFloat32sAsc(x []float32)
- func SortFloat32sDesc(x []float32)
- func SortFloat64sAsc(x []float64)
- func SortFloat64sDesc(x []float64)
- func SortInt16sAsc(x []int16)
- func SortInt16sDesc(x []int16)
- func SortInt32sAsc(x []int32)
- func SortInt32sDesc(x []int32)
- func SortInt64sAsc(x []int64)
- func SortInt64sDesc(x []int64)
- func SortInt8sAsc(x []int8)
- func SortInt8sDesc(x []int8)
- func SortIntsAsc(x []int)
- func SortIntsDesc(x []int)
- func SortStringsAsc(x []string)
- func SortStringsDesc(x []string)
- func SortUint16sAsc(x []uint16)
- func SortUint16sDesc(x []uint16)
- func SortUint32sAsc(x []uint32)
- func SortUint32sDesc(x []uint32)
- func SortUint64sAsc(x []uint64)
- func SortUint64sDesc(x []uint64)
- func SortUint8sAsc(x []uint8)
- func SortUint8sDesc(x []uint8)
- func SortUintptrsAsc(x []uintptr)
- func SortUintptrsDesc(x []uintptr)
- func SortUintsAsc(x []uint)
- func SortUintsDesc(x []uint)
- func SplitInt32s(slice []int32, batch int) [][]int32
- func SplitInt64s(slice []int64, batch int) [][]int64
- func SplitSlice(slice interface{}, batch int) interface{}
- func SplitStrings(slice []string, batch int) [][]string
- func StringsAreSortedAsc(x []string) bool
- func StringsAreSortedDesc(x []string) bool
- func SumSlice(slice interface{}) int64
- func ToInterfaceSlice(slice interface{}) []interface{}
- func ToMap(slice interface{}, keyField string) interface{}
- func ToMapMap(slice interface{}, keyField, subKeyField string) interface{}
- func ToSliceMap(slice interface{}, keyField string) interface{}
- func Uint16sAreSortedAsc(x []uint16) bool
- func Uint16sAreSortedDesc(x []uint16) bool
- func Uint32sAreSortedAsc(x []uint32) bool
- func Uint32sAreSortedDesc(x []uint32) bool
- func Uint64sAreSortedAsc(x []uint64) bool
- func Uint64sAreSortedDesc(x []uint64) bool
- func Uint8sAreSortedAsc(x []uint8) bool
- func Uint8sAreSortedDesc(x []uint8) bool
- func UintptrsAreSortedAsc(x []uintptr) bool
- func UintptrsAreSortedDesc(x []uintptr) bool
- func UintsAreSortedAsc(x []uint) bool
- func UintsAreSortedDesc(x []uint) bool
- func UniqueInt32s(slice []int32, inplace bool) []int32
- func UniqueInt64s(slice []int64, inplace bool) []int64
- func UniqueStrings(slice []string, inplace bool) []string
- func XMLToReader(obj interface{}) (io.Reader, error)
- type DebugLogger
- type ErrDebugLogger
- type ErrLogger
- type Float32sAsc
- type Float32sDesc
- type Float64sAsc
- type Float64sDesc
- type IJ
- type Int16sAsc
- type Int16sDesc
- type Int32sAsc
- type Int32sDesc
- type Int64sAsc
- type Int64sDesc
- type Int8sAsc
- type Int8sDesc
- type IntsAsc
- type IntsDesc
- type LogCfg
- type Map
- type PanicError
- type PrintFunc
- type Request
- type SafeMap
- type StringsAsc
- type StringsDesc
- type Uint16sAsc
- type Uint16sDesc
- type Uint32sAsc
- type Uint32sDesc
- type Uint64sAsc
- type Uint64sDesc
- type Uint8sAsc
- type Uint8sDesc
- type UintptrsAsc
- type UintptrsDesc
- type UintsAsc
- type UintsDesc
Constants ¶
This section is empty.
Variables ¶
var ( NewMap = gemap.NewMap NewSafeMap = gemap.NewSafeMap )
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 )
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 ¶
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 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 ¶
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 ¶
DecodeJSON decodes a json value from r.
func DiffInt32s ¶
DiffInt32s returns a new int32 slice containing the values which present in slice a but not present in slice b.
func DiffInt64s ¶
DiffInt64s returns a new int64 slice containing the values which present in slice a but not present in slice b.
func DiffStrings ¶
DiffStrings returns a new string slice containing the values which present in slice a but not present in slice b.
func DoRequest ¶
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
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
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
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
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
FindFunc returns the first element in the slice for which predicate returns true.
func Float32sAreSortedAsc ¶ added in v0.7.0
Float32sAreSortedAsc is a convenience method which calls sort.IsSorted(Float32sAsc(x)).
func Float32sAreSortedDesc ¶ added in v0.7.0
Float32sAreSortedDesc is a convenience method which calls sort.IsSorted(Float32sDesc(x)).
func Float64sAreSortedAsc ¶ added in v0.7.0
Float64sAreSortedAsc is a convenience method which calls sort.IsSorted(Float64sAsc(x)).
func Float64sAreSortedDesc ¶ added in v0.7.0
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 InSliceFunc ¶ added in v0.7.0
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
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
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
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 ¶
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 ¶
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
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 ¶
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 ¶
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
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
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
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
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
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
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 IndexFunc ¶ added in v0.7.0
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 ¶
IndexInt32s returns the index of the first instance of elem slice, or -1 if elem is not present in slice.
func IndexInt64s ¶
IndexInt64s returns the index of the first instance of elem in slice, or -1 if elem is not present in slice.
func IndexStrings ¶
IndexStrings returns the index of the first instance of elem in slice, or -1 if elem is not present in slice.
func InsertInt32s ¶
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 ¶
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 ¶
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
Int16sAreSortedAsc is a convenience method which calls sort.IsSorted(Int16sAsc(x)).
func Int16sAreSortedDesc ¶ added in v0.7.0
Int16sAreSortedDesc is a convenience method which calls sort.IsSorted(Int16sDesc(x)).
func Int32sAreSortedAsc ¶ added in v0.7.0
Int32sAreSortedAsc is a convenience method which calls sort.IsSorted(Int32sAsc(x)).
func Int32sAreSortedDesc ¶ added in v0.7.0
Int32sAreSortedDesc is a convenience method which calls sort.IsSorted(Int32sDesc(x)).
func Int64sAreSortedAsc ¶ added in v0.7.0
Int64sAreSortedAsc is a convenience method which calls sort.IsSorted(Int64sAsc(x)).
func Int64sAreSortedDesc ¶ added in v0.7.0
Int64sAreSortedDesc is a convenience method which calls sort.IsSorted(Int64sDesc(x)).
func Int8sAreSortedAsc ¶ added in v0.7.0
Int8sAreSortedAsc is a convenience method which calls sort.IsSorted(Int8sAsc(x)).
func Int8sAreSortedDesc ¶ added in v0.7.0
Int8sAreSortedDesc is a convenience method which calls sort.IsSorted(Int8sDesc(x)).
func IntsAreSortedAsc ¶ added in v0.7.0
IntsAreSortedAsc is a convenience method which calls sort.IsSorted(IntsAsc(x)).
func IntsAreSortedDesc ¶ added in v0.7.0
IntsAreSortedDesc is a convenience method which calls sort.IsSorted(IntsDesc(x)).
func IsJSONType ¶
IsJSONType method is to check JSON 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 ¶
JSONToReader converts an json encodeable object to an io.Reader. If obj cannot be marshaled as JSON, it reports the error.
func JoinInt64s ¶
JoinInt64s returns a string consisting of slice elements separated by sep.
func LastIndexFunc ¶ added in v0.7.0
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 ¶
LastIndexInt32s returns the index of the last instance of elem in slice, or -1 if elem is not present in slice.
func LastIndexInt64s ¶
LastIndexInt64s returns the index of the last instance of elem in slice, or -1 if elem is not present in slice.
func LastIndexStrings ¶
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
MatchGroups returns the matched named capturing groups. A returned value of nil indicates no match.
func MatchStringGroups ¶ added in v0.6.0
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 ¶
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
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
SplitInt32s splits a large int32 slice to batches.
func SplitInt64s ¶ added in v0.9.0
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
SplitStrings splits a large string slice to batches.
func StringsAreSortedAsc ¶ added in v0.7.0
StringsAreSortedAsc is a convenience method which calls sort.IsSorted(StringsAsc(x)).
func StringsAreSortedDesc ¶ added in v0.7.0
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
Uint16sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint16sAsc(x)).
func Uint16sAreSortedDesc ¶ added in v0.7.0
Uint16sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint16sDesc(x)).
func Uint32sAreSortedAsc ¶ added in v0.7.0
Uint32sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint32sAsc(x)).
func Uint32sAreSortedDesc ¶ added in v0.7.0
Uint32sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint32sDesc(x)).
func Uint64sAreSortedAsc ¶ added in v0.7.0
Uint64sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint64sAsc(x)).
func Uint64sAreSortedDesc ¶ added in v0.7.0
Uint64sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint64sDesc(x)).
func Uint8sAreSortedAsc ¶ added in v0.7.0
Uint8sAreSortedAsc is a convenience method which calls sort.IsSorted(Uint8sAsc(x)).
func Uint8sAreSortedDesc ¶ added in v0.7.0
Uint8sAreSortedDesc is a convenience method which calls sort.IsSorted(Uint8sDesc(x)).
func UintptrsAreSortedAsc ¶ added in v0.7.0
UintptrsAreSortedAsc is a convenience method which calls sort.IsSorted(UintptrsAsc(x)).
func UintptrsAreSortedDesc ¶ added in v0.7.0
UintptrsAreSortedDesc is a convenience method which calls sort.IsSorted(UintptrsDesc(x)).
func UintsAreSortedAsc ¶ added in v0.7.0
UintsAreSortedAsc is a convenience method which calls sort.IsSorted(UintsAsc(x)).
func UintsAreSortedDesc ¶ added in v0.7.0
UintsAreSortedDesc is a convenience method which calls sort.IsSorted(UintsDesc(x)).
func UniqueInt32s ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.
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.
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.
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.
type Int8sDesc ¶ added in v0.7.0
type Int8sDesc []int8
Int8sDesc attaches the methods of sort.Interface to []int8, sorting in descending order.
type IntsAsc ¶ added in v0.7.0
type IntsAsc []int
IntsAsc attaches the methods of sort.Interface to []int, sorting in ascending order.
type IntsDesc ¶ added in v0.7.0
type IntsDesc []int
IntsDesc attaches the methods of sort.Interface to []int, sorting in descending order.
type LogCfg ¶ added in v0.4.0
type LogCfg struct { EnableDebug func() bool Logger func() ErrDebugLogger CtxLogger func(context.Context) ErrDebugLogger }
type PanicError ¶
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`.
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 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.
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.