Copyright 2017, The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE.md file.
Package cmpopts provides common options for the cmp package.
EquateEmpty returns a Comparer option that determines all maps and slices with a length of zero to be equal, regardless of whether they are nil. EquateEmpty can be used in conjunction with SortSlices and SortMaps.
EquateApprox returns a Comparer option that determines float32 or float64 values to be equal if they are within a relative fraction or absolute margin. This option is not used when either x or y is NaN or infinite. The fraction determines that the difference of two values must be within the smaller fraction of the two values, while the margin determines that the two values must be within some absolute margin. To express only a fraction or only a margin, use 0 for the other parameter. The fraction and margin must be non-negative. The mathematical expression used is equivalent to: |x-y| ≤ max(fraction*min(|x|, |y|), margin) EquateApprox can be used in conjunction with EquateNaNs.
EquateNaNs returns a Comparer option that determines float32 and float64 NaN values to be equal. EquateNaNs can be used in conjunction with EquateApprox.
EquateApproxTime returns a Comparer option that determines two non-zero time.Time values to be equal if they are within some margin of one another. If both times have a monotonic clock reading, then the monotonic time difference will be used. The margin must be non-negative.
EquateErrors returns a Comparer option that determines errors to be equal if errors.Is reports them to match. The AnyError error can be used to match any non-nil error.
areConcreteErrors reports whether x and y are types that implement error. The input types are deliberately of the interface{} type rather than the error type so that we can handle situations where the current type is an interface{}, but the underlying concrete types both happen to implement the error interface.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.