diff --git a/cmp/cmpopts/equate.go b/cmp/cmpopts/equate.go index 62837c9..1dace8b 100644 --- a/cmp/cmpopts/equate.go +++ b/cmp/cmpopts/equate.go @@ -6,6 +6,7 @@ package cmpopts import ( + "errors" "math" "reflect" "time" @@ -136,6 +137,12 @@ func EquateErrors() cmp.Option { return cmp.FilterValues(areConcreteErrors, cmp.Comparer(compareErrors)) } +func compareErrors(x, y interface{}) bool { + xe := x.(error) + ye := y.(error) + return errors.Is(xe, ye) || errors.Is(ye, xe) +} + // 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 diff --git a/cmp/cmpopts/errors_go113.go b/cmp/cmpopts/errors_go113.go deleted file mode 100644 index 8eb2b84..0000000 --- a/cmp/cmpopts/errors_go113.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2021, 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 file. - -//go:build go1.13 -// +build go1.13 - -package cmpopts - -import "errors" - -func compareErrors(x, y interface{}) bool { - xe := x.(error) - ye := y.(error) - return errors.Is(xe, ye) || errors.Is(ye, xe) -} diff --git a/go.mod b/go.mod index b570017..f55cea6 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/google/go-cmp -go 1.11 +go 1.13