vendor: github.com/google/go-cmp v0.5.9 to remove golang.org/x/xerrors dep
full diff: https://github.com/google/go-cmp/compare/v0.5.7...v0.5.9
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 57ba2df970
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
2fd846d40f
commit
83f90039ef
30 changed files with 136 additions and 878 deletions
|
@ -37,7 +37,7 @@ require (
|
||||||
github.com/godbus/dbus/v5 v5.0.6
|
github.com/godbus/dbus/v5 v5.0.6
|
||||||
github.com/gogo/protobuf v1.3.2
|
github.com/gogo/protobuf v1.3.2
|
||||||
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2
|
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2
|
||||||
github.com/google/go-cmp v0.5.7
|
github.com/google/go-cmp v0.5.9
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/hashicorp/go-immutable-radix v1.3.1
|
github.com/hashicorp/go-immutable-radix v1.3.1
|
||||||
|
@ -161,7 +161,6 @@ require (
|
||||||
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
|
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
|
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
|
||||||
google.golang.org/api v0.54.0 // indirect
|
google.golang.org/api v0.54.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/protobuf v1.28.0 // indirect
|
google.golang.org/protobuf v1.28.0 // indirect
|
||||||
|
|
|
@ -549,8 +549,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
|
||||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
|
github.com/google/go-containerregistry v0.5.1/go.mod h1:Ct15B4yir3PLOP5jsy0GNeYVaIZs/MK/Jz5any1wFW0=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
@ -1521,7 +1522,6 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
|
||||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
|
|
8
vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go
generated
vendored
8
vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go
generated
vendored
|
@ -6,6 +6,7 @@
|
||||||
package cmpopts
|
package cmpopts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"math"
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
@ -41,6 +42,7 @@ func isEmpty(x, y interface{}) bool {
|
||||||
// The fraction and margin must be non-negative.
|
// The fraction and margin must be non-negative.
|
||||||
//
|
//
|
||||||
// The mathematical expression used is equivalent to:
|
// The mathematical expression used is equivalent to:
|
||||||
|
//
|
||||||
// |x-y| ≤ max(fraction*min(|x|, |y|), margin)
|
// |x-y| ≤ max(fraction*min(|x|, |y|), margin)
|
||||||
//
|
//
|
||||||
// EquateApprox can be used in conjunction with EquateNaNs.
|
// EquateApprox can be used in conjunction with EquateNaNs.
|
||||||
|
@ -146,3 +148,9 @@ func areConcreteErrors(x, y interface{}) bool {
|
||||||
_, ok2 := y.(error)
|
_, ok2 := y.(error)
|
||||||
return ok1 && ok2
|
return ok1 && ok2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func compareErrors(x, y interface{}) bool {
|
||||||
|
xe := x.(error)
|
||||||
|
ye := y.(error)
|
||||||
|
return errors.Is(xe, ye) || errors.Is(ye, xe)
|
||||||
|
}
|
||||||
|
|
16
vendor/github.com/google/go-cmp/cmp/cmpopts/errors_go113.go
generated
vendored
16
vendor/github.com/google/go-cmp/cmp/cmpopts/errors_go113.go
generated
vendored
|
@ -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)
|
|
||||||
}
|
|
19
vendor/github.com/google/go-cmp/cmp/cmpopts/errors_xerrors.go
generated
vendored
19
vendor/github.com/google/go-cmp/cmp/cmpopts/errors_xerrors.go
generated
vendored
|
@ -1,19 +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
|
|
||||||
|
|
||||||
// TODO(≥go1.13): For support on <go1.13, we use the xerrors package.
|
|
||||||
// Drop this file when we no longer support older Go versions.
|
|
||||||
|
|
||||||
package cmpopts
|
|
||||||
|
|
||||||
import "golang.org/x/xerrors"
|
|
||||||
|
|
||||||
func compareErrors(x, y interface{}) bool {
|
|
||||||
xe := x.(error)
|
|
||||||
ye := y.(error)
|
|
||||||
return xerrors.Is(xe, ye) || xerrors.Is(ye, xe)
|
|
||||||
}
|
|
14
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
14
vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go
generated
vendored
|
@ -18,9 +18,9 @@ import (
|
||||||
// sort any slice with element type V that is assignable to T.
|
// sort any slice with element type V that is assignable to T.
|
||||||
//
|
//
|
||||||
// The less function must be:
|
// The less function must be:
|
||||||
// • Deterministic: less(x, y) == less(x, y)
|
// - Deterministic: less(x, y) == less(x, y)
|
||||||
// • Irreflexive: !less(x, x)
|
// - Irreflexive: !less(x, x)
|
||||||
// • Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||||
//
|
//
|
||||||
// The less function does not have to be "total". That is, if !less(x, y) and
|
// The less function does not have to be "total". That is, if !less(x, y) and
|
||||||
// !less(y, x) for two elements x and y, their relative order is maintained.
|
// !less(y, x) for two elements x and y, their relative order is maintained.
|
||||||
|
@ -91,10 +91,10 @@ func (ss sliceSorter) less(v reflect.Value, i, j int) bool {
|
||||||
// use Comparers on K or the K.Equal method if it exists.
|
// use Comparers on K or the K.Equal method if it exists.
|
||||||
//
|
//
|
||||||
// The less function must be:
|
// The less function must be:
|
||||||
// • Deterministic: less(x, y) == less(x, y)
|
// - Deterministic: less(x, y) == less(x, y)
|
||||||
// • Irreflexive: !less(x, x)
|
// - Irreflexive: !less(x, x)
|
||||||
// • Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
// - Transitive: if !less(x, y) and !less(y, z), then !less(x, z)
|
||||||
// • Total: if x != y, then either less(x, y) or less(y, x)
|
// - Total: if x != y, then either less(x, y) or less(y, x)
|
||||||
//
|
//
|
||||||
// SortMaps can be used in conjunction with EquateEmpty.
|
// SortMaps can be used in conjunction with EquateEmpty.
|
||||||
func SortMaps(lessFunc interface{}) cmp.Option {
|
func SortMaps(lessFunc interface{}) cmp.Option {
|
||||||
|
|
2
vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go
generated
vendored
2
vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go
generated
vendored
|
@ -67,12 +67,14 @@ func (sf structFilter) filter(p cmp.Path) bool {
|
||||||
// fieldTree represents a set of dot-separated identifiers.
|
// fieldTree represents a set of dot-separated identifiers.
|
||||||
//
|
//
|
||||||
// For example, inserting the following selectors:
|
// For example, inserting the following selectors:
|
||||||
|
//
|
||||||
// Foo
|
// Foo
|
||||||
// Foo.Bar.Baz
|
// Foo.Bar.Baz
|
||||||
// Foo.Buzz
|
// Foo.Buzz
|
||||||
// Nuka.Cola.Quantum
|
// Nuka.Cola.Quantum
|
||||||
//
|
//
|
||||||
// Results in a tree of the form:
|
// Results in a tree of the form:
|
||||||
|
//
|
||||||
// {sub: {
|
// {sub: {
|
||||||
// "Foo": {ok: true, sub: {
|
// "Foo": {ok: true, sub: {
|
||||||
// "Bar": {sub: {
|
// "Bar": {sub: {
|
||||||
|
|
1
vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go
generated
vendored
1
vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go
generated
vendored
|
@ -23,6 +23,7 @@ func (xf xformFilter) filter(p cmp.Path) bool {
|
||||||
// that the transformer cannot be recursively applied upon its own output.
|
// that the transformer cannot be recursively applied upon its own output.
|
||||||
//
|
//
|
||||||
// An example use case is a transformer that splits a string by lines:
|
// An example use case is a transformer that splits a string by lines:
|
||||||
|
//
|
||||||
// AcyclicTransformer("SplitLines", func(s string) []string{
|
// AcyclicTransformer("SplitLines", func(s string) []string{
|
||||||
// return strings.Split(s, "\n")
|
// return strings.Split(s, "\n")
|
||||||
// })
|
// })
|
||||||
|
|
66
vendor/github.com/google/go-cmp/cmp/compare.go
generated
vendored
66
vendor/github.com/google/go-cmp/cmp/compare.go
generated
vendored
|
@ -13,21 +13,21 @@
|
||||||
//
|
//
|
||||||
// The primary features of cmp are:
|
// The primary features of cmp are:
|
||||||
//
|
//
|
||||||
// • When the default behavior of equality does not suit the needs of the test,
|
// - When the default behavior of equality does not suit the test's needs,
|
||||||
// custom equality functions can override the equality operation.
|
// custom equality functions can override the equality operation.
|
||||||
// For example, an equality function may report floats as equal so long as they
|
// For example, an equality function may report floats as equal so long as
|
||||||
// are within some tolerance of each other.
|
// they are within some tolerance of each other.
|
||||||
//
|
//
|
||||||
// • Types that have an Equal method may use that method to determine equality.
|
// - Types with an Equal method may use that method to determine equality.
|
||||||
// This allows package authors to determine the equality operation for the types
|
// This allows package authors to determine the equality operation
|
||||||
// that they define.
|
// for the types that they define.
|
||||||
//
|
//
|
||||||
// • If no custom equality functions are used and no Equal method is defined,
|
// - If no custom equality functions are used and no Equal method is defined,
|
||||||
// equality is determined by recursively comparing the primitive kinds on both
|
// equality is determined by recursively comparing the primitive kinds on
|
||||||
// values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported
|
// both values, much like reflect.DeepEqual. Unlike reflect.DeepEqual,
|
||||||
// fields are not compared by default; they result in panics unless suppressed
|
// unexported fields are not compared by default; they result in panics
|
||||||
// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly
|
// unless suppressed by using an Ignore option (see cmpopts.IgnoreUnexported)
|
||||||
// compared using the Exporter option.
|
// or explicitly compared using the Exporter option.
|
||||||
package cmp
|
package cmp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -40,28 +40,30 @@ import (
|
||||||
"github.com/google/go-cmp/cmp/internal/value"
|
"github.com/google/go-cmp/cmp/internal/value"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO(≥go1.18): Use any instead of interface{}.
|
||||||
|
|
||||||
// Equal reports whether x and y are equal by recursively applying the
|
// Equal reports whether x and y are equal by recursively applying the
|
||||||
// following rules in the given order to x and y and all of their sub-values:
|
// following rules in the given order to x and y and all of their sub-values:
|
||||||
//
|
//
|
||||||
// • Let S be the set of all Ignore, Transformer, and Comparer options that
|
// - Let S be the set of all Ignore, Transformer, and Comparer options that
|
||||||
// remain after applying all path filters, value filters, and type filters.
|
// remain after applying all path filters, value filters, and type filters.
|
||||||
// If at least one Ignore exists in S, then the comparison is ignored.
|
// If at least one Ignore exists in S, then the comparison is ignored.
|
||||||
// If the number of Transformer and Comparer options in S is greater than one,
|
// If the number of Transformer and Comparer options in S is non-zero,
|
||||||
// then Equal panics because it is ambiguous which option to use.
|
// then Equal panics because it is ambiguous which option to use.
|
||||||
// If S contains a single Transformer, then use that to transform the current
|
// If S contains a single Transformer, then use that to transform
|
||||||
// values and recursively call Equal on the output values.
|
// the current values and recursively call Equal on the output values.
|
||||||
// If S contains a single Comparer, then use that to compare the current values.
|
// If S contains a single Comparer, then use that to compare the current values.
|
||||||
// Otherwise, evaluation proceeds to the next rule.
|
// Otherwise, evaluation proceeds to the next rule.
|
||||||
//
|
//
|
||||||
// • If the values have an Equal method of the form "(T) Equal(T) bool" or
|
// - If the values have an Equal method of the form "(T) Equal(T) bool" or
|
||||||
// "(T) Equal(I) bool" where T is assignable to I, then use the result of
|
// "(T) Equal(I) bool" where T is assignable to I, then use the result of
|
||||||
// x.Equal(y) even if x or y is nil. Otherwise, no such method exists and
|
// x.Equal(y) even if x or y is nil. Otherwise, no such method exists and
|
||||||
// evaluation proceeds to the next rule.
|
// evaluation proceeds to the next rule.
|
||||||
//
|
//
|
||||||
// • Lastly, try to compare x and y based on their basic kinds.
|
// - Lastly, try to compare x and y based on their basic kinds.
|
||||||
// Simple kinds like booleans, integers, floats, complex numbers, strings, and
|
// Simple kinds like booleans, integers, floats, complex numbers, strings,
|
||||||
// channels are compared using the equivalent of the == operator in Go.
|
// and channels are compared using the equivalent of the == operator in Go.
|
||||||
// Functions are only equal if they are both nil, otherwise they are unequal.
|
// Functions are only equal if they are both nil, otherwise they are unequal.
|
||||||
//
|
//
|
||||||
// Structs are equal if recursively calling Equal on all fields report equal.
|
// Structs are equal if recursively calling Equal on all fields report equal.
|
||||||
// If a struct contains unexported fields, Equal panics unless an Ignore option
|
// If a struct contains unexported fields, Equal panics unless an Ignore option
|
||||||
|
@ -142,7 +144,7 @@ func rootStep(x, y interface{}) PathStep {
|
||||||
// so that they have the same parent type.
|
// so that they have the same parent type.
|
||||||
var t reflect.Type
|
var t reflect.Type
|
||||||
if !vx.IsValid() || !vy.IsValid() || vx.Type() != vy.Type() {
|
if !vx.IsValid() || !vy.IsValid() || vx.Type() != vy.Type() {
|
||||||
t = reflect.TypeOf((*interface{})(nil)).Elem()
|
t = anyType
|
||||||
if vx.IsValid() {
|
if vx.IsValid() {
|
||||||
vvx := reflect.New(t).Elem()
|
vvx := reflect.New(t).Elem()
|
||||||
vvx.Set(vx)
|
vvx.Set(vx)
|
||||||
|
@ -637,7 +639,9 @@ type dynChecker struct{ curr, next int }
|
||||||
// Next increments the state and reports whether a check should be performed.
|
// Next increments the state and reports whether a check should be performed.
|
||||||
//
|
//
|
||||||
// Checks occur every Nth function call, where N is a triangular number:
|
// Checks occur every Nth function call, where N is a triangular number:
|
||||||
|
//
|
||||||
// 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 ...
|
// 0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 ...
|
||||||
|
//
|
||||||
// See https://en.wikipedia.org/wiki/Triangular_number
|
// See https://en.wikipedia.org/wiki/Triangular_number
|
||||||
//
|
//
|
||||||
// This sequence ensures that the cost of checks drops significantly as
|
// This sequence ensures that the cost of checks drops significantly as
|
||||||
|
|
44
vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go
generated
vendored
44
vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go
generated
vendored
|
@ -127,9 +127,9 @@ var randBool = rand.New(rand.NewSource(time.Now().Unix())).Intn(2) == 0
|
||||||
// This function returns an edit-script, which is a sequence of operations
|
// This function returns an edit-script, which is a sequence of operations
|
||||||
// needed to convert one list into the other. The following invariants for
|
// needed to convert one list into the other. The following invariants for
|
||||||
// the edit-script are maintained:
|
// the edit-script are maintained:
|
||||||
// • eq == (es.Dist()==0)
|
// - eq == (es.Dist()==0)
|
||||||
// • nx == es.LenX()
|
// - nx == es.LenX()
|
||||||
// • ny == es.LenY()
|
// - ny == es.LenY()
|
||||||
//
|
//
|
||||||
// This algorithm is not guaranteed to be an optimal solution (i.e., one that
|
// This algorithm is not guaranteed to be an optimal solution (i.e., one that
|
||||||
// produces an edit-script with a minimal Levenshtein distance). This algorithm
|
// produces an edit-script with a minimal Levenshtein distance). This algorithm
|
||||||
|
@ -169,12 +169,13 @@ func Difference(nx, ny int, f EqualFunc) (es EditScript) {
|
||||||
// A diagonal edge is equivalent to a matching symbol between both X and Y.
|
// A diagonal edge is equivalent to a matching symbol between both X and Y.
|
||||||
|
|
||||||
// Invariants:
|
// Invariants:
|
||||||
// • 0 ≤ fwdPath.X ≤ (fwdFrontier.X, revFrontier.X) ≤ revPath.X ≤ nx
|
// - 0 ≤ fwdPath.X ≤ (fwdFrontier.X, revFrontier.X) ≤ revPath.X ≤ nx
|
||||||
// • 0 ≤ fwdPath.Y ≤ (fwdFrontier.Y, revFrontier.Y) ≤ revPath.Y ≤ ny
|
// - 0 ≤ fwdPath.Y ≤ (fwdFrontier.Y, revFrontier.Y) ≤ revPath.Y ≤ ny
|
||||||
//
|
//
|
||||||
// In general:
|
// In general:
|
||||||
// • fwdFrontier.X < revFrontier.X
|
// - fwdFrontier.X < revFrontier.X
|
||||||
// • fwdFrontier.Y < revFrontier.Y
|
// - fwdFrontier.Y < revFrontier.Y
|
||||||
|
//
|
||||||
// Unless, it is time for the algorithm to terminate.
|
// Unless, it is time for the algorithm to terminate.
|
||||||
fwdPath := path{+1, point{0, 0}, make(EditScript, 0, (nx+ny)/2)}
|
fwdPath := path{+1, point{0, 0}, make(EditScript, 0, (nx+ny)/2)}
|
||||||
revPath := path{-1, point{nx, ny}, make(EditScript, 0)}
|
revPath := path{-1, point{nx, ny}, make(EditScript, 0)}
|
||||||
|
@ -195,19 +196,21 @@ func Difference(nx, ny int, f EqualFunc) (es EditScript) {
|
||||||
// computing sub-optimal edit-scripts between two lists.
|
// computing sub-optimal edit-scripts between two lists.
|
||||||
//
|
//
|
||||||
// The algorithm is approximately as follows:
|
// The algorithm is approximately as follows:
|
||||||
// • Searching for differences switches back-and-forth between
|
// - Searching for differences switches back-and-forth between
|
||||||
// a search that starts at the beginning (the top-left corner), and
|
// a search that starts at the beginning (the top-left corner), and
|
||||||
// a search that starts at the end (the bottom-right corner). The goal of
|
// a search that starts at the end (the bottom-right corner).
|
||||||
// the search is connect with the search from the opposite corner.
|
// The goal of the search is connect with the search
|
||||||
// • As we search, we build a path in a greedy manner, where the first
|
// from the opposite corner.
|
||||||
// match seen is added to the path (this is sub-optimal, but provides a
|
// - As we search, we build a path in a greedy manner,
|
||||||
// decent result in practice). When matches are found, we try the next pair
|
// where the first match seen is added to the path (this is sub-optimal,
|
||||||
// of symbols in the lists and follow all matches as far as possible.
|
// but provides a decent result in practice). When matches are found,
|
||||||
// • When searching for matches, we search along a diagonal going through
|
// we try the next pair of symbols in the lists and follow all matches
|
||||||
// through the "frontier" point. If no matches are found, we advance the
|
// as far as possible.
|
||||||
// frontier towards the opposite corner.
|
// - When searching for matches, we search along a diagonal going through
|
||||||
// • This algorithm terminates when either the X coordinates or the
|
// through the "frontier" point. If no matches are found,
|
||||||
// Y coordinates of the forward and reverse frontier points ever intersect.
|
// we advance the frontier towards the opposite corner.
|
||||||
|
// - This algorithm terminates when either the X coordinates or the
|
||||||
|
// Y coordinates of the forward and reverse frontier points ever intersect.
|
||||||
|
|
||||||
// This algorithm is correct even if searching only in the forward direction
|
// This algorithm is correct even if searching only in the forward direction
|
||||||
// or in the reverse direction. We do both because it is commonly observed
|
// or in the reverse direction. We do both because it is commonly observed
|
||||||
|
@ -389,6 +392,7 @@ type point struct{ X, Y int }
|
||||||
func (p *point) add(dx, dy int) { p.X += dx; p.Y += dy }
|
func (p *point) add(dx, dy int) { p.X += dx; p.Y += dy }
|
||||||
|
|
||||||
// zigzag maps a consecutive sequence of integers to a zig-zag sequence.
|
// zigzag maps a consecutive sequence of integers to a zig-zag sequence.
|
||||||
|
//
|
||||||
// [0 1 2 3 4 5 ...] => [0 -1 +1 -2 +2 ...]
|
// [0 1 2 3 4 5 ...] => [0 -1 +1 -2 +2 ...]
|
||||||
func zigzag(x int) int {
|
func zigzag(x int) int {
|
||||||
if x&1 != 0 {
|
if x&1 != 0 {
|
||||||
|
|
48
vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
generated
vendored
48
vendor/github.com/google/go-cmp/cmp/internal/value/zero.go
generated
vendored
|
@ -1,48 +0,0 @@
|
||||||
// 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 file.
|
|
||||||
|
|
||||||
package value
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsZero reports whether v is the zero value.
|
|
||||||
// This does not rely on Interface and so can be used on unexported fields.
|
|
||||||
func IsZero(v reflect.Value) bool {
|
|
||||||
switch v.Kind() {
|
|
||||||
case reflect.Bool:
|
|
||||||
return v.Bool() == false
|
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
|
||||||
return v.Int() == 0
|
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
|
||||||
return v.Uint() == 0
|
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
return math.Float64bits(v.Float()) == 0
|
|
||||||
case reflect.Complex64, reflect.Complex128:
|
|
||||||
return math.Float64bits(real(v.Complex())) == 0 && math.Float64bits(imag(v.Complex())) == 0
|
|
||||||
case reflect.String:
|
|
||||||
return v.String() == ""
|
|
||||||
case reflect.UnsafePointer:
|
|
||||||
return v.Pointer() == 0
|
|
||||||
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice:
|
|
||||||
return v.IsNil()
|
|
||||||
case reflect.Array:
|
|
||||||
for i := 0; i < v.Len(); i++ {
|
|
||||||
if !IsZero(v.Index(i)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
case reflect.Struct:
|
|
||||||
for i := 0; i < v.NumField(); i++ {
|
|
||||||
if !IsZero(v.Field(i)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
10
vendor/github.com/google/go-cmp/cmp/options.go
generated
vendored
10
vendor/github.com/google/go-cmp/cmp/options.go
generated
vendored
|
@ -33,6 +33,7 @@ type Option interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// applicableOption represents the following types:
|
// applicableOption represents the following types:
|
||||||
|
//
|
||||||
// Fundamental: ignore | validator | *comparer | *transformer
|
// Fundamental: ignore | validator | *comparer | *transformer
|
||||||
// Grouping: Options
|
// Grouping: Options
|
||||||
type applicableOption interface {
|
type applicableOption interface {
|
||||||
|
@ -43,6 +44,7 @@ type applicableOption interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// coreOption represents the following types:
|
// coreOption represents the following types:
|
||||||
|
//
|
||||||
// Fundamental: ignore | validator | *comparer | *transformer
|
// Fundamental: ignore | validator | *comparer | *transformer
|
||||||
// Filters: *pathFilter | *valuesFilter
|
// Filters: *pathFilter | *valuesFilter
|
||||||
type coreOption interface {
|
type coreOption interface {
|
||||||
|
@ -336,9 +338,9 @@ func (tr transformer) String() string {
|
||||||
// both implement T.
|
// both implement T.
|
||||||
//
|
//
|
||||||
// The equality function must be:
|
// The equality function must be:
|
||||||
// • Symmetric: equal(x, y) == equal(y, x)
|
// - Symmetric: equal(x, y) == equal(y, x)
|
||||||
// • Deterministic: equal(x, y) == equal(x, y)
|
// - Deterministic: equal(x, y) == equal(x, y)
|
||||||
// • Pure: equal(x, y) does not modify x or y
|
// - Pure: equal(x, y) does not modify x or y
|
||||||
func Comparer(f interface{}) Option {
|
func Comparer(f interface{}) Option {
|
||||||
v := reflect.ValueOf(f)
|
v := reflect.ValueOf(f)
|
||||||
if !function.IsType(v.Type(), function.Equal) || v.IsNil() {
|
if !function.IsType(v.Type(), function.Equal) || v.IsNil() {
|
||||||
|
@ -430,7 +432,7 @@ func AllowUnexported(types ...interface{}) Option {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result represents the comparison result for a single node and
|
// Result represents the comparison result for a single node and
|
||||||
// is provided by cmp when calling Result (see Reporter).
|
// is provided by cmp when calling Report (see Reporter).
|
||||||
type Result struct {
|
type Result struct {
|
||||||
_ [0]func() // Make Result incomparable
|
_ [0]func() // Make Result incomparable
|
||||||
flags resultFlags
|
flags resultFlags
|
||||||
|
|
20
vendor/github.com/google/go-cmp/cmp/path.go
generated
vendored
20
vendor/github.com/google/go-cmp/cmp/path.go
generated
vendored
|
@ -41,13 +41,13 @@ type PathStep interface {
|
||||||
// The type of each valid value is guaranteed to be identical to Type.
|
// The type of each valid value is guaranteed to be identical to Type.
|
||||||
//
|
//
|
||||||
// In some cases, one or both may be invalid or have restrictions:
|
// In some cases, one or both may be invalid or have restrictions:
|
||||||
// • For StructField, both are not interface-able if the current field
|
// - For StructField, both are not interface-able if the current field
|
||||||
// is unexported and the struct type is not explicitly permitted by
|
// is unexported and the struct type is not explicitly permitted by
|
||||||
// an Exporter to traverse unexported fields.
|
// an Exporter to traverse unexported fields.
|
||||||
// • For SliceIndex, one may be invalid if an element is missing from
|
// - For SliceIndex, one may be invalid if an element is missing from
|
||||||
// either the x or y slice.
|
// either the x or y slice.
|
||||||
// • For MapIndex, one may be invalid if an entry is missing from
|
// - For MapIndex, one may be invalid if an entry is missing from
|
||||||
// either the x or y map.
|
// either the x or y map.
|
||||||
//
|
//
|
||||||
// The provided values must not be mutated.
|
// The provided values must not be mutated.
|
||||||
Values() (vx, vy reflect.Value)
|
Values() (vx, vy reflect.Value)
|
||||||
|
@ -94,6 +94,7 @@ func (pa Path) Index(i int) PathStep {
|
||||||
// The simplified path only contains struct field accesses.
|
// The simplified path only contains struct field accesses.
|
||||||
//
|
//
|
||||||
// For example:
|
// For example:
|
||||||
|
//
|
||||||
// MyMap.MySlices.MyField
|
// MyMap.MySlices.MyField
|
||||||
func (pa Path) String() string {
|
func (pa Path) String() string {
|
||||||
var ss []string
|
var ss []string
|
||||||
|
@ -108,6 +109,7 @@ func (pa Path) String() string {
|
||||||
// GoString returns the path to a specific node using Go syntax.
|
// GoString returns the path to a specific node using Go syntax.
|
||||||
//
|
//
|
||||||
// For example:
|
// For example:
|
||||||
|
//
|
||||||
// (*root.MyMap["key"].(*mypkg.MyStruct).MySlices)[2][3].MyField
|
// (*root.MyMap["key"].(*mypkg.MyStruct).MySlices)[2][3].MyField
|
||||||
func (pa Path) GoString() string {
|
func (pa Path) GoString() string {
|
||||||
var ssPre, ssPost []string
|
var ssPre, ssPost []string
|
||||||
|
@ -159,7 +161,7 @@ func (ps pathStep) String() string {
|
||||||
if ps.typ == nil {
|
if ps.typ == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
s := ps.typ.String()
|
s := value.TypeString(ps.typ, false)
|
||||||
if s == "" || strings.ContainsAny(s, "{}\n") {
|
if s == "" || strings.ContainsAny(s, "{}\n") {
|
||||||
return "root" // Type too simple or complex to print
|
return "root" // Type too simple or complex to print
|
||||||
}
|
}
|
||||||
|
@ -282,7 +284,7 @@ type typeAssertion struct {
|
||||||
|
|
||||||
func (ta TypeAssertion) Type() reflect.Type { return ta.typ }
|
func (ta TypeAssertion) Type() reflect.Type { return ta.typ }
|
||||||
func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy }
|
func (ta TypeAssertion) Values() (vx, vy reflect.Value) { return ta.vx, ta.vy }
|
||||||
func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", ta.typ) }
|
func (ta TypeAssertion) String() string { return fmt.Sprintf(".(%v)", value.TypeString(ta.typ, false)) }
|
||||||
|
|
||||||
// Transform is a transformation from the parent type to the current type.
|
// Transform is a transformation from the parent type to the current type.
|
||||||
type Transform struct{ *transform }
|
type Transform struct{ *transform }
|
||||||
|
|
13
vendor/github.com/google/go-cmp/cmp/report_compare.go
generated
vendored
13
vendor/github.com/google/go-cmp/cmp/report_compare.go
generated
vendored
|
@ -7,8 +7,6 @@ package cmp
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp/internal/value"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// numContextRecords is the number of surrounding equal records to print.
|
// numContextRecords is the number of surrounding equal records to print.
|
||||||
|
@ -116,7 +114,10 @@ func (opts formatOptions) FormatDiff(v *valueNode, ptrs *pointerReferences) (out
|
||||||
}
|
}
|
||||||
|
|
||||||
// For leaf nodes, format the value based on the reflect.Values alone.
|
// For leaf nodes, format the value based on the reflect.Values alone.
|
||||||
if v.MaxDepth == 0 {
|
// As a special case, treat equal []byte as a leaf nodes.
|
||||||
|
isBytes := v.Type.Kind() == reflect.Slice && v.Type.Elem() == byteType
|
||||||
|
isEqualBytes := isBytes && v.NumDiff+v.NumIgnored+v.NumTransformed == 0
|
||||||
|
if v.MaxDepth == 0 || isEqualBytes {
|
||||||
switch opts.DiffMode {
|
switch opts.DiffMode {
|
||||||
case diffUnknown, diffIdentical:
|
case diffUnknown, diffIdentical:
|
||||||
// Format Equal.
|
// Format Equal.
|
||||||
|
@ -245,11 +246,11 @@ func (opts formatOptions) formatDiffList(recs []reportRecord, k reflect.Kind, pt
|
||||||
var isZero bool
|
var isZero bool
|
||||||
switch opts.DiffMode {
|
switch opts.DiffMode {
|
||||||
case diffIdentical:
|
case diffIdentical:
|
||||||
isZero = value.IsZero(r.Value.ValueX) || value.IsZero(r.Value.ValueY)
|
isZero = r.Value.ValueX.IsZero() || r.Value.ValueY.IsZero()
|
||||||
case diffRemoved:
|
case diffRemoved:
|
||||||
isZero = value.IsZero(r.Value.ValueX)
|
isZero = r.Value.ValueX.IsZero()
|
||||||
case diffInserted:
|
case diffInserted:
|
||||||
isZero = value.IsZero(r.Value.ValueY)
|
isZero = r.Value.ValueY.IsZero()
|
||||||
}
|
}
|
||||||
if isZero {
|
if isZero {
|
||||||
continue
|
continue
|
||||||
|
|
21
vendor/github.com/google/go-cmp/cmp/report_reflect.go
generated
vendored
21
vendor/github.com/google/go-cmp/cmp/report_reflect.go
generated
vendored
|
@ -16,6 +16,13 @@ import (
|
||||||
"github.com/google/go-cmp/cmp/internal/value"
|
"github.com/google/go-cmp/cmp/internal/value"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
anyType = reflect.TypeOf((*interface{})(nil)).Elem()
|
||||||
|
stringType = reflect.TypeOf((*string)(nil)).Elem()
|
||||||
|
bytesType = reflect.TypeOf((*[]byte)(nil)).Elem()
|
||||||
|
byteType = reflect.TypeOf((*byte)(nil)).Elem()
|
||||||
|
)
|
||||||
|
|
||||||
type formatValueOptions struct {
|
type formatValueOptions struct {
|
||||||
// AvoidStringer controls whether to avoid calling custom stringer
|
// AvoidStringer controls whether to avoid calling custom stringer
|
||||||
// methods like error.Error or fmt.Stringer.String.
|
// methods like error.Error or fmt.Stringer.String.
|
||||||
|
@ -184,7 +191,7 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
|
||||||
}
|
}
|
||||||
for i := 0; i < v.NumField(); i++ {
|
for i := 0; i < v.NumField(); i++ {
|
||||||
vv := v.Field(i)
|
vv := v.Field(i)
|
||||||
if value.IsZero(vv) {
|
if vv.IsZero() {
|
||||||
continue // Elide fields with zero values
|
continue // Elide fields with zero values
|
||||||
}
|
}
|
||||||
if len(list) == maxLen {
|
if len(list) == maxLen {
|
||||||
|
@ -205,13 +212,13 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether this is a []byte of text data.
|
// Check whether this is a []byte of text data.
|
||||||
if t.Elem() == reflect.TypeOf(byte(0)) {
|
if t.Elem() == byteType {
|
||||||
b := v.Bytes()
|
b := v.Bytes()
|
||||||
isPrintSpace := func(r rune) bool { return unicode.IsPrint(r) || unicode.IsSpace(r) }
|
isPrintSpace := func(r rune) bool { return unicode.IsPrint(r) || unicode.IsSpace(r) }
|
||||||
if len(b) > 0 && utf8.Valid(b) && len(bytes.TrimFunc(b, isPrintSpace)) == 0 {
|
if len(b) > 0 && utf8.Valid(b) && len(bytes.TrimFunc(b, isPrintSpace)) == 0 {
|
||||||
out = opts.formatString("", string(b))
|
out = opts.formatString("", string(b))
|
||||||
skipType = true
|
skipType = true
|
||||||
return opts.WithTypeMode(emitType).FormatType(t, out)
|
return opts.FormatType(t, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +289,12 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
|
||||||
}
|
}
|
||||||
defer ptrs.Pop()
|
defer ptrs.Pop()
|
||||||
|
|
||||||
skipType = true // Let the underlying value print the type instead
|
// Skip the name only if this is an unnamed pointer type.
|
||||||
|
// Otherwise taking the address of a value does not reproduce
|
||||||
|
// the named pointer type.
|
||||||
|
if v.Type().Name() == "" {
|
||||||
|
skipType = true // Let the underlying value print the type instead
|
||||||
|
}
|
||||||
out = opts.FormatValue(v.Elem(), t.Kind(), ptrs)
|
out = opts.FormatValue(v.Elem(), t.Kind(), ptrs)
|
||||||
out = wrapTrunkReference(ptrRef, opts.PrintAddresses, out)
|
out = wrapTrunkReference(ptrRef, opts.PrintAddresses, out)
|
||||||
out = &textWrap{Prefix: "&", Value: out}
|
out = &textWrap{Prefix: "&", Value: out}
|
||||||
|
@ -293,7 +305,6 @@ func (opts formatOptions) FormatValue(v reflect.Value, parentKind reflect.Kind,
|
||||||
}
|
}
|
||||||
// Interfaces accept different concrete types,
|
// Interfaces accept different concrete types,
|
||||||
// so configure the underlying value to explicitly print the type.
|
// so configure the underlying value to explicitly print the type.
|
||||||
skipType = true // Print the concrete type instead
|
|
||||||
return opts.WithTypeMode(emitType).FormatValue(v.Elem(), t.Kind(), ptrs)
|
return opts.WithTypeMode(emitType).FormatValue(v.Elem(), t.Kind(), ptrs)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("%v kind not handled", v.Kind()))
|
panic(fmt.Sprintf("%v kind not handled", v.Kind()))
|
||||||
|
|
25
vendor/github.com/google/go-cmp/cmp/report_slices.go
generated
vendored
25
vendor/github.com/google/go-cmp/cmp/report_slices.go
generated
vendored
|
@ -104,7 +104,7 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode {
|
||||||
case t.Kind() == reflect.String:
|
case t.Kind() == reflect.String:
|
||||||
sx, sy = vx.String(), vy.String()
|
sx, sy = vx.String(), vy.String()
|
||||||
isString = true
|
isString = true
|
||||||
case t.Kind() == reflect.Slice && t.Elem() == reflect.TypeOf(byte(0)):
|
case t.Kind() == reflect.Slice && t.Elem() == byteType:
|
||||||
sx, sy = string(vx.Bytes()), string(vy.Bytes())
|
sx, sy = string(vx.Bytes()), string(vy.Bytes())
|
||||||
isString = true
|
isString = true
|
||||||
case t.Kind() == reflect.Array:
|
case t.Kind() == reflect.Array:
|
||||||
|
@ -147,7 +147,10 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode {
|
||||||
})
|
})
|
||||||
efficiencyLines := float64(esLines.Dist()) / float64(len(esLines))
|
efficiencyLines := float64(esLines.Dist()) / float64(len(esLines))
|
||||||
efficiencyBytes := float64(esBytes.Dist()) / float64(len(esBytes))
|
efficiencyBytes := float64(esBytes.Dist()) / float64(len(esBytes))
|
||||||
isPureLinedText = efficiencyLines < 4*efficiencyBytes
|
quotedLength := len(strconv.Quote(sx + sy))
|
||||||
|
unquotedLength := len(sx) + len(sy)
|
||||||
|
escapeExpansionRatio := float64(quotedLength) / float64(unquotedLength)
|
||||||
|
isPureLinedText = efficiencyLines < 4*efficiencyBytes || escapeExpansionRatio > 1.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,12 +174,13 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode {
|
||||||
// differences in a string literal. This format is more readable,
|
// differences in a string literal. This format is more readable,
|
||||||
// but has edge-cases where differences are visually indistinguishable.
|
// but has edge-cases where differences are visually indistinguishable.
|
||||||
// This format is avoided under the following conditions:
|
// This format is avoided under the following conditions:
|
||||||
// • A line starts with `"""`
|
// - A line starts with `"""`
|
||||||
// • A line starts with "..."
|
// - A line starts with "..."
|
||||||
// • A line contains non-printable characters
|
// - A line contains non-printable characters
|
||||||
// • Adjacent different lines differ only by whitespace
|
// - Adjacent different lines differ only by whitespace
|
||||||
//
|
//
|
||||||
// For example:
|
// For example:
|
||||||
|
//
|
||||||
// """
|
// """
|
||||||
// ... // 3 identical lines
|
// ... // 3 identical lines
|
||||||
// foo
|
// foo
|
||||||
|
@ -231,7 +235,7 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode {
|
||||||
var out textNode = &textWrap{Prefix: "(", Value: list2, Suffix: ")"}
|
var out textNode = &textWrap{Prefix: "(", Value: list2, Suffix: ")"}
|
||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
if t != reflect.TypeOf(string("")) {
|
if t != stringType {
|
||||||
out = opts.FormatType(t, out)
|
out = opts.FormatType(t, out)
|
||||||
}
|
}
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
|
@ -326,12 +330,12 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode {
|
||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
out = &textWrap{Prefix: "strings.Join(", Value: out, Suffix: fmt.Sprintf(", %q)", delim)}
|
out = &textWrap{Prefix: "strings.Join(", Value: out, Suffix: fmt.Sprintf(", %q)", delim)}
|
||||||
if t != reflect.TypeOf(string("")) {
|
if t != stringType {
|
||||||
out = opts.FormatType(t, out)
|
out = opts.FormatType(t, out)
|
||||||
}
|
}
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
out = &textWrap{Prefix: "bytes.Join(", Value: out, Suffix: fmt.Sprintf(", %q)", delim)}
|
out = &textWrap{Prefix: "bytes.Join(", Value: out, Suffix: fmt.Sprintf(", %q)", delim)}
|
||||||
if t != reflect.TypeOf([]byte(nil)) {
|
if t != bytesType {
|
||||||
out = opts.FormatType(t, out)
|
out = opts.FormatType(t, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -446,7 +450,6 @@ func (opts formatOptions) formatDiffSlice(
|
||||||
// {NumIdentical: 3},
|
// {NumIdentical: 3},
|
||||||
// {NumInserted: 1},
|
// {NumInserted: 1},
|
||||||
// ]
|
// ]
|
||||||
//
|
|
||||||
func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats) {
|
func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats) {
|
||||||
var prevMode byte
|
var prevMode byte
|
||||||
lastStats := func(mode byte) *diffStats {
|
lastStats := func(mode byte) *diffStats {
|
||||||
|
@ -503,7 +506,6 @@ func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats)
|
||||||
// {NumIdentical: 8, NumRemoved: 12, NumInserted: 3},
|
// {NumIdentical: 8, NumRemoved: 12, NumInserted: 3},
|
||||||
// {NumIdentical: 63},
|
// {NumIdentical: 63},
|
||||||
// ]
|
// ]
|
||||||
//
|
|
||||||
func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStats {
|
func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStats {
|
||||||
groups, groupsOrig := groups[:0], groups
|
groups, groupsOrig := groups[:0], groups
|
||||||
for i, ds := range groupsOrig {
|
for i, ds := range groupsOrig {
|
||||||
|
@ -548,7 +550,6 @@ func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStat
|
||||||
// {NumRemoved: 9},
|
// {NumRemoved: 9},
|
||||||
// {NumIdentical: 64}, // incremented by 10
|
// {NumIdentical: 64}, // incremented by 10
|
||||||
// ]
|
// ]
|
||||||
//
|
|
||||||
func cleanupSurroundingIdentical(groups []diffStats, eq func(i, j int) bool) []diffStats {
|
func cleanupSurroundingIdentical(groups []diffStats, eq func(i, j int) bool) []diffStats {
|
||||||
var ix, iy int // indexes into sequence x and y
|
var ix, iy int // indexes into sequence x and y
|
||||||
for i, ds := range groups {
|
for i, ds := range groups {
|
||||||
|
|
1
vendor/github.com/google/go-cmp/cmp/report_text.go
generated
vendored
1
vendor/github.com/google/go-cmp/cmp/report_text.go
generated
vendored
|
@ -393,6 +393,7 @@ func (s diffStats) Append(ds diffStats) diffStats {
|
||||||
// String prints a humanly-readable summary of coalesced records.
|
// String prints a humanly-readable summary of coalesced records.
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
|
//
|
||||||
// diffStats{Name: "Field", NumIgnored: 5}.String() => "5 ignored fields"
|
// diffStats{Name: "Field", NumIgnored: 5}.String() => "5 ignored fields"
|
||||||
func (s diffStats) String() string {
|
func (s diffStats) String() string {
|
||||||
var ss []string
|
var ss []string
|
||||||
|
|
27
vendor/golang.org/x/xerrors/LICENSE
generated
vendored
27
vendor/golang.org/x/xerrors/LICENSE
generated
vendored
|
@ -1,27 +0,0 @@
|
||||||
Copyright (c) 2019 The Go Authors. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
vendor/golang.org/x/xerrors/PATENTS
generated
vendored
22
vendor/golang.org/x/xerrors/PATENTS
generated
vendored
|
@ -1,22 +0,0 @@
|
||||||
Additional IP Rights Grant (Patents)
|
|
||||||
|
|
||||||
"This implementation" means the copyrightable works distributed by
|
|
||||||
Google as part of the Go project.
|
|
||||||
|
|
||||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
||||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
|
||||||
patent license to make, have made, use, offer to sell, sell, import,
|
|
||||||
transfer and otherwise run, modify and propagate the contents of this
|
|
||||||
implementation of Go, where such license applies only to those patent
|
|
||||||
claims, both currently owned or controlled by Google and acquired in
|
|
||||||
the future, licensable by Google that are necessarily infringed by this
|
|
||||||
implementation of Go. This grant does not include claims that would be
|
|
||||||
infringed only as a consequence of further modification of this
|
|
||||||
implementation. If you or your agent or exclusive licensee institute or
|
|
||||||
order or agree to the institution of patent litigation against any
|
|
||||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
|
||||||
that this implementation of Go or any code incorporated within this
|
|
||||||
implementation of Go constitutes direct or contributory patent
|
|
||||||
infringement, or inducement of patent infringement, then any patent
|
|
||||||
rights granted to you under this License for this implementation of Go
|
|
||||||
shall terminate as of the date such litigation is filed.
|
|
2
vendor/golang.org/x/xerrors/README
generated
vendored
2
vendor/golang.org/x/xerrors/README
generated
vendored
|
@ -1,2 +0,0 @@
|
||||||
This repository holds the transition packages for the new Go 1.13 error values.
|
|
||||||
See golang.org/design/29934-error-values.
|
|
193
vendor/golang.org/x/xerrors/adaptor.go
generated
vendored
193
vendor/golang.org/x/xerrors/adaptor.go
generated
vendored
|
@ -1,193 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"reflect"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FormatError calls the FormatError method of f with an errors.Printer
|
|
||||||
// configured according to s and verb, and writes the result to s.
|
|
||||||
func FormatError(f Formatter, s fmt.State, verb rune) {
|
|
||||||
// Assuming this function is only called from the Format method, and given
|
|
||||||
// that FormatError takes precedence over Format, it cannot be called from
|
|
||||||
// any package that supports errors.Formatter. It is therefore safe to
|
|
||||||
// disregard that State may be a specific printer implementation and use one
|
|
||||||
// of our choice instead.
|
|
||||||
|
|
||||||
// limitations: does not support printing error as Go struct.
|
|
||||||
|
|
||||||
var (
|
|
||||||
sep = " " // separator before next error
|
|
||||||
p = &state{State: s}
|
|
||||||
direct = true
|
|
||||||
)
|
|
||||||
|
|
||||||
var err error = f
|
|
||||||
|
|
||||||
switch verb {
|
|
||||||
// Note that this switch must match the preference order
|
|
||||||
// for ordinary string printing (%#v before %+v, and so on).
|
|
||||||
|
|
||||||
case 'v':
|
|
||||||
if s.Flag('#') {
|
|
||||||
if stringer, ok := err.(fmt.GoStringer); ok {
|
|
||||||
io.WriteString(&p.buf, stringer.GoString())
|
|
||||||
goto exit
|
|
||||||
}
|
|
||||||
// proceed as if it were %v
|
|
||||||
} else if s.Flag('+') {
|
|
||||||
p.printDetail = true
|
|
||||||
sep = "\n - "
|
|
||||||
}
|
|
||||||
case 's':
|
|
||||||
case 'q', 'x', 'X':
|
|
||||||
// Use an intermediate buffer in the rare cases that precision,
|
|
||||||
// truncation, or one of the alternative verbs (q, x, and X) are
|
|
||||||
// specified.
|
|
||||||
direct = false
|
|
||||||
|
|
||||||
default:
|
|
||||||
p.buf.WriteString("%!")
|
|
||||||
p.buf.WriteRune(verb)
|
|
||||||
p.buf.WriteByte('(')
|
|
||||||
switch {
|
|
||||||
case err != nil:
|
|
||||||
p.buf.WriteString(reflect.TypeOf(f).String())
|
|
||||||
default:
|
|
||||||
p.buf.WriteString("<nil>")
|
|
||||||
}
|
|
||||||
p.buf.WriteByte(')')
|
|
||||||
io.Copy(s, &p.buf)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
switch v := err.(type) {
|
|
||||||
case Formatter:
|
|
||||||
err = v.FormatError((*printer)(p))
|
|
||||||
case fmt.Formatter:
|
|
||||||
v.Format(p, 'v')
|
|
||||||
break loop
|
|
||||||
default:
|
|
||||||
io.WriteString(&p.buf, v.Error())
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if p.needColon || !p.printDetail {
|
|
||||||
p.buf.WriteByte(':')
|
|
||||||
p.needColon = false
|
|
||||||
}
|
|
||||||
p.buf.WriteString(sep)
|
|
||||||
p.inDetail = false
|
|
||||||
p.needNewline = false
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
width, okW := s.Width()
|
|
||||||
prec, okP := s.Precision()
|
|
||||||
|
|
||||||
if !direct || (okW && width > 0) || okP {
|
|
||||||
// Construct format string from State s.
|
|
||||||
format := []byte{'%'}
|
|
||||||
if s.Flag('-') {
|
|
||||||
format = append(format, '-')
|
|
||||||
}
|
|
||||||
if s.Flag('+') {
|
|
||||||
format = append(format, '+')
|
|
||||||
}
|
|
||||||
if s.Flag(' ') {
|
|
||||||
format = append(format, ' ')
|
|
||||||
}
|
|
||||||
if okW {
|
|
||||||
format = strconv.AppendInt(format, int64(width), 10)
|
|
||||||
}
|
|
||||||
if okP {
|
|
||||||
format = append(format, '.')
|
|
||||||
format = strconv.AppendInt(format, int64(prec), 10)
|
|
||||||
}
|
|
||||||
format = append(format, string(verb)...)
|
|
||||||
fmt.Fprintf(s, string(format), p.buf.String())
|
|
||||||
} else {
|
|
||||||
io.Copy(s, &p.buf)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var detailSep = []byte("\n ")
|
|
||||||
|
|
||||||
// state tracks error printing state. It implements fmt.State.
|
|
||||||
type state struct {
|
|
||||||
fmt.State
|
|
||||||
buf bytes.Buffer
|
|
||||||
|
|
||||||
printDetail bool
|
|
||||||
inDetail bool
|
|
||||||
needColon bool
|
|
||||||
needNewline bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *state) Write(b []byte) (n int, err error) {
|
|
||||||
if s.printDetail {
|
|
||||||
if len(b) == 0 {
|
|
||||||
return 0, nil
|
|
||||||
}
|
|
||||||
if s.inDetail && s.needColon {
|
|
||||||
s.needNewline = true
|
|
||||||
if b[0] == '\n' {
|
|
||||||
b = b[1:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
k := 0
|
|
||||||
for i, c := range b {
|
|
||||||
if s.needNewline {
|
|
||||||
if s.inDetail && s.needColon {
|
|
||||||
s.buf.WriteByte(':')
|
|
||||||
s.needColon = false
|
|
||||||
}
|
|
||||||
s.buf.Write(detailSep)
|
|
||||||
s.needNewline = false
|
|
||||||
}
|
|
||||||
if c == '\n' {
|
|
||||||
s.buf.Write(b[k:i])
|
|
||||||
k = i + 1
|
|
||||||
s.needNewline = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.buf.Write(b[k:])
|
|
||||||
if !s.inDetail {
|
|
||||||
s.needColon = true
|
|
||||||
}
|
|
||||||
} else if !s.inDetail {
|
|
||||||
s.buf.Write(b)
|
|
||||||
}
|
|
||||||
return len(b), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// printer wraps a state to implement an xerrors.Printer.
|
|
||||||
type printer state
|
|
||||||
|
|
||||||
func (s *printer) Print(args ...interface{}) {
|
|
||||||
if !s.inDetail || s.printDetail {
|
|
||||||
fmt.Fprint((*state)(s), args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *printer) Printf(format string, args ...interface{}) {
|
|
||||||
if !s.inDetail || s.printDetail {
|
|
||||||
fmt.Fprintf((*state)(s), format, args...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *printer) Detail() bool {
|
|
||||||
s.inDetail = true
|
|
||||||
return s.printDetail
|
|
||||||
}
|
|
1
vendor/golang.org/x/xerrors/codereview.cfg
generated
vendored
1
vendor/golang.org/x/xerrors/codereview.cfg
generated
vendored
|
@ -1 +0,0 @@
|
||||||
issuerepo: golang/go
|
|
22
vendor/golang.org/x/xerrors/doc.go
generated
vendored
22
vendor/golang.org/x/xerrors/doc.go
generated
vendored
|
@ -1,22 +0,0 @@
|
||||||
// Copyright 2019 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.
|
|
||||||
|
|
||||||
// Package xerrors implements functions to manipulate errors.
|
|
||||||
//
|
|
||||||
// This package is based on the Go 2 proposal for error values:
|
|
||||||
// https://golang.org/design/29934-error-values
|
|
||||||
//
|
|
||||||
// These functions were incorporated into the standard library's errors package
|
|
||||||
// in Go 1.13:
|
|
||||||
// - Is
|
|
||||||
// - As
|
|
||||||
// - Unwrap
|
|
||||||
//
|
|
||||||
// Also, Errorf's %w verb was incorporated into fmt.Errorf.
|
|
||||||
//
|
|
||||||
// Use this package to get equivalent behavior in all supported Go versions.
|
|
||||||
//
|
|
||||||
// No other features of this package were included in Go 1.13, and at present
|
|
||||||
// there are no plans to include any of them.
|
|
||||||
package xerrors // import "golang.org/x/xerrors"
|
|
33
vendor/golang.org/x/xerrors/errors.go
generated
vendored
33
vendor/golang.org/x/xerrors/errors.go
generated
vendored
|
@ -1,33 +0,0 @@
|
||||||
// Copyright 2011 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// errorString is a trivial implementation of error.
|
|
||||||
type errorString struct {
|
|
||||||
s string
|
|
||||||
frame Frame
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns an error that formats as the given text.
|
|
||||||
//
|
|
||||||
// The returned error contains a Frame set to the caller's location and
|
|
||||||
// implements Formatter to show this information when printed with details.
|
|
||||||
func New(text string) error {
|
|
||||||
return &errorString{text, Caller(1)}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *errorString) Error() string {
|
|
||||||
return e.s
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) }
|
|
||||||
|
|
||||||
func (e *errorString) FormatError(p Printer) (next error) {
|
|
||||||
p.Print(e.s)
|
|
||||||
e.frame.Format(p)
|
|
||||||
return nil
|
|
||||||
}
|
|
187
vendor/golang.org/x/xerrors/fmt.go
generated
vendored
187
vendor/golang.org/x/xerrors/fmt.go
generated
vendored
|
@ -1,187 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"unicode"
|
|
||||||
"unicode/utf8"
|
|
||||||
|
|
||||||
"golang.org/x/xerrors/internal"
|
|
||||||
)
|
|
||||||
|
|
||||||
const percentBangString = "%!"
|
|
||||||
|
|
||||||
// Errorf formats according to a format specifier and returns the string as a
|
|
||||||
// value that satisfies error.
|
|
||||||
//
|
|
||||||
// The returned error includes the file and line number of the caller when
|
|
||||||
// formatted with additional detail enabled. If the last argument is an error
|
|
||||||
// the returned error's Format method will return it if the format string ends
|
|
||||||
// with ": %s", ": %v", or ": %w". If the last argument is an error and the
|
|
||||||
// format string ends with ": %w", the returned error implements an Unwrap
|
|
||||||
// method returning it.
|
|
||||||
//
|
|
||||||
// If the format specifier includes a %w verb with an error operand in a
|
|
||||||
// position other than at the end, the returned error will still implement an
|
|
||||||
// Unwrap method returning the operand, but the error's Format method will not
|
|
||||||
// return the wrapped error.
|
|
||||||
//
|
|
||||||
// It is invalid to include more than one %w verb or to supply it with an
|
|
||||||
// operand that does not implement the error interface. The %w verb is otherwise
|
|
||||||
// a synonym for %v.
|
|
||||||
func Errorf(format string, a ...interface{}) error {
|
|
||||||
format = formatPlusW(format)
|
|
||||||
// Support a ": %[wsv]" suffix, which works well with xerrors.Formatter.
|
|
||||||
wrap := strings.HasSuffix(format, ": %w")
|
|
||||||
idx, format2, ok := parsePercentW(format)
|
|
||||||
percentWElsewhere := !wrap && idx >= 0
|
|
||||||
if !percentWElsewhere && (wrap || strings.HasSuffix(format, ": %s") || strings.HasSuffix(format, ": %v")) {
|
|
||||||
err := errorAt(a, len(a)-1)
|
|
||||||
if err == nil {
|
|
||||||
return &noWrapError{fmt.Sprintf(format, a...), nil, Caller(1)}
|
|
||||||
}
|
|
||||||
// TODO: this is not entirely correct. The error value could be
|
|
||||||
// printed elsewhere in format if it mixes numbered with unnumbered
|
|
||||||
// substitutions. With relatively small changes to doPrintf we can
|
|
||||||
// have it optionally ignore extra arguments and pass the argument
|
|
||||||
// list in its entirety.
|
|
||||||
msg := fmt.Sprintf(format[:len(format)-len(": %s")], a[:len(a)-1]...)
|
|
||||||
frame := Frame{}
|
|
||||||
if internal.EnableTrace {
|
|
||||||
frame = Caller(1)
|
|
||||||
}
|
|
||||||
if wrap {
|
|
||||||
return &wrapError{msg, err, frame}
|
|
||||||
}
|
|
||||||
return &noWrapError{msg, err, frame}
|
|
||||||
}
|
|
||||||
// Support %w anywhere.
|
|
||||||
// TODO: don't repeat the wrapped error's message when %w occurs in the middle.
|
|
||||||
msg := fmt.Sprintf(format2, a...)
|
|
||||||
if idx < 0 {
|
|
||||||
return &noWrapError{msg, nil, Caller(1)}
|
|
||||||
}
|
|
||||||
err := errorAt(a, idx)
|
|
||||||
if !ok || err == nil {
|
|
||||||
// Too many %ws or argument of %w is not an error. Approximate the Go
|
|
||||||
// 1.13 fmt.Errorf message.
|
|
||||||
return &noWrapError{fmt.Sprintf("%sw(%s)", percentBangString, msg), nil, Caller(1)}
|
|
||||||
}
|
|
||||||
frame := Frame{}
|
|
||||||
if internal.EnableTrace {
|
|
||||||
frame = Caller(1)
|
|
||||||
}
|
|
||||||
return &wrapError{msg, err, frame}
|
|
||||||
}
|
|
||||||
|
|
||||||
func errorAt(args []interface{}, i int) error {
|
|
||||||
if i < 0 || i >= len(args) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
err, ok := args[i].(error)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// formatPlusW is used to avoid the vet check that will barf at %w.
|
|
||||||
func formatPlusW(s string) string {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the index of the only %w in format, or -1 if none.
|
|
||||||
// Also return a rewritten format string with %w replaced by %v, and
|
|
||||||
// false if there is more than one %w.
|
|
||||||
// TODO: handle "%[N]w".
|
|
||||||
func parsePercentW(format string) (idx int, newFormat string, ok bool) {
|
|
||||||
// Loosely copied from golang.org/x/tools/go/analysis/passes/printf/printf.go.
|
|
||||||
idx = -1
|
|
||||||
ok = true
|
|
||||||
n := 0
|
|
||||||
sz := 0
|
|
||||||
var isW bool
|
|
||||||
for i := 0; i < len(format); i += sz {
|
|
||||||
if format[i] != '%' {
|
|
||||||
sz = 1
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// "%%" is not a format directive.
|
|
||||||
if i+1 < len(format) && format[i+1] == '%' {
|
|
||||||
sz = 2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
sz, isW = parsePrintfVerb(format[i:])
|
|
||||||
if isW {
|
|
||||||
if idx >= 0 {
|
|
||||||
ok = false
|
|
||||||
} else {
|
|
||||||
idx = n
|
|
||||||
}
|
|
||||||
// "Replace" the last character, the 'w', with a 'v'.
|
|
||||||
p := i + sz - 1
|
|
||||||
format = format[:p] + "v" + format[p+1:]
|
|
||||||
}
|
|
||||||
n++
|
|
||||||
}
|
|
||||||
return idx, format, ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the printf verb starting with a % at s[0].
|
|
||||||
// Return how many bytes it occupies and whether the verb is 'w'.
|
|
||||||
func parsePrintfVerb(s string) (int, bool) {
|
|
||||||
// Assume only that the directive is a sequence of non-letters followed by a single letter.
|
|
||||||
sz := 0
|
|
||||||
var r rune
|
|
||||||
for i := 1; i < len(s); i += sz {
|
|
||||||
r, sz = utf8.DecodeRuneInString(s[i:])
|
|
||||||
if unicode.IsLetter(r) {
|
|
||||||
return i + sz, r == 'w'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return len(s), false
|
|
||||||
}
|
|
||||||
|
|
||||||
type noWrapError struct {
|
|
||||||
msg string
|
|
||||||
err error
|
|
||||||
frame Frame
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *noWrapError) Error() string {
|
|
||||||
return fmt.Sprint(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *noWrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) }
|
|
||||||
|
|
||||||
func (e *noWrapError) FormatError(p Printer) (next error) {
|
|
||||||
p.Print(e.msg)
|
|
||||||
e.frame.Format(p)
|
|
||||||
return e.err
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapError struct {
|
|
||||||
msg string
|
|
||||||
err error
|
|
||||||
frame Frame
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *wrapError) Error() string {
|
|
||||||
return fmt.Sprint(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *wrapError) Format(s fmt.State, v rune) { FormatError(e, s, v) }
|
|
||||||
|
|
||||||
func (e *wrapError) FormatError(p Printer) (next error) {
|
|
||||||
p.Print(e.msg)
|
|
||||||
e.frame.Format(p)
|
|
||||||
return e.err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *wrapError) Unwrap() error {
|
|
||||||
return e.err
|
|
||||||
}
|
|
34
vendor/golang.org/x/xerrors/format.go
generated
vendored
34
vendor/golang.org/x/xerrors/format.go
generated
vendored
|
@ -1,34 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
// A Formatter formats error messages.
|
|
||||||
type Formatter interface {
|
|
||||||
error
|
|
||||||
|
|
||||||
// FormatError prints the receiver's first error and returns the next error in
|
|
||||||
// the error chain, if any.
|
|
||||||
FormatError(p Printer) (next error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Printer formats error messages.
|
|
||||||
//
|
|
||||||
// The most common implementation of Printer is the one provided by package fmt
|
|
||||||
// during Printf (as of Go 1.13). Localization packages such as golang.org/x/text/message
|
|
||||||
// typically provide their own implementations.
|
|
||||||
type Printer interface {
|
|
||||||
// Print appends args to the message output.
|
|
||||||
Print(args ...interface{})
|
|
||||||
|
|
||||||
// Printf writes a formatted string.
|
|
||||||
Printf(format string, args ...interface{})
|
|
||||||
|
|
||||||
// Detail reports whether error detail is requested.
|
|
||||||
// After the first call to Detail, all text written to the Printer
|
|
||||||
// is formatted as additional detail, or ignored when
|
|
||||||
// detail has not been requested.
|
|
||||||
// If Detail returns false, the caller can avoid printing the detail at all.
|
|
||||||
Detail() bool
|
|
||||||
}
|
|
56
vendor/golang.org/x/xerrors/frame.go
generated
vendored
56
vendor/golang.org/x/xerrors/frame.go
generated
vendored
|
@ -1,56 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
import (
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Frame contains part of a call stack.
|
|
||||||
type Frame struct {
|
|
||||||
// Make room for three PCs: the one we were asked for, what it called,
|
|
||||||
// and possibly a PC for skipPleaseUseCallersFrames. See:
|
|
||||||
// https://go.googlesource.com/go/+/032678e0fb/src/runtime/extern.go#169
|
|
||||||
frames [3]uintptr
|
|
||||||
}
|
|
||||||
|
|
||||||
// Caller returns a Frame that describes a frame on the caller's stack.
|
|
||||||
// The argument skip is the number of frames to skip over.
|
|
||||||
// Caller(0) returns the frame for the caller of Caller.
|
|
||||||
func Caller(skip int) Frame {
|
|
||||||
var s Frame
|
|
||||||
runtime.Callers(skip+1, s.frames[:])
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// location reports the file, line, and function of a frame.
|
|
||||||
//
|
|
||||||
// The returned function may be "" even if file and line are not.
|
|
||||||
func (f Frame) location() (function, file string, line int) {
|
|
||||||
frames := runtime.CallersFrames(f.frames[:])
|
|
||||||
if _, ok := frames.Next(); !ok {
|
|
||||||
return "", "", 0
|
|
||||||
}
|
|
||||||
fr, ok := frames.Next()
|
|
||||||
if !ok {
|
|
||||||
return "", "", 0
|
|
||||||
}
|
|
||||||
return fr.Function, fr.File, fr.Line
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format prints the stack as error detail.
|
|
||||||
// It should be called from an error's Format implementation
|
|
||||||
// after printing any other error detail.
|
|
||||||
func (f Frame) Format(p Printer) {
|
|
||||||
if p.Detail() {
|
|
||||||
function, file, line := f.location()
|
|
||||||
if function != "" {
|
|
||||||
p.Printf("%s\n ", function)
|
|
||||||
}
|
|
||||||
if file != "" {
|
|
||||||
p.Printf("%s:%d\n", file, line)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
8
vendor/golang.org/x/xerrors/internal/internal.go
generated
vendored
8
vendor/golang.org/x/xerrors/internal/internal.go
generated
vendored
|
@ -1,8 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package internal
|
|
||||||
|
|
||||||
// EnableTrace indicates whether stack information should be recorded in errors.
|
|
||||||
var EnableTrace = true
|
|
106
vendor/golang.org/x/xerrors/wrap.go
generated
vendored
106
vendor/golang.org/x/xerrors/wrap.go
generated
vendored
|
@ -1,106 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
package xerrors
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// A Wrapper provides context around another error.
|
|
||||||
type Wrapper interface {
|
|
||||||
// Unwrap returns the next error in the error chain.
|
|
||||||
// If there is no next error, Unwrap returns nil.
|
|
||||||
Unwrap() error
|
|
||||||
}
|
|
||||||
|
|
||||||
// Opaque returns an error with the same error formatting as err
|
|
||||||
// but that does not match err and cannot be unwrapped.
|
|
||||||
func Opaque(err error) error {
|
|
||||||
return noWrapper{err}
|
|
||||||
}
|
|
||||||
|
|
||||||
type noWrapper struct {
|
|
||||||
error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e noWrapper) FormatError(p Printer) (next error) {
|
|
||||||
if f, ok := e.error.(Formatter); ok {
|
|
||||||
return f.FormatError(p)
|
|
||||||
}
|
|
||||||
p.Print(e.error)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unwrap returns the result of calling the Unwrap method on err, if err implements
|
|
||||||
// Unwrap. Otherwise, Unwrap returns nil.
|
|
||||||
func Unwrap(err error) error {
|
|
||||||
u, ok := err.(Wrapper)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return u.Unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is reports whether any error in err's chain matches target.
|
|
||||||
//
|
|
||||||
// An error is considered to match a target if it is equal to that target or if
|
|
||||||
// it implements a method Is(error) bool such that Is(target) returns true.
|
|
||||||
func Is(err, target error) bool {
|
|
||||||
if target == nil {
|
|
||||||
return err == target
|
|
||||||
}
|
|
||||||
|
|
||||||
isComparable := reflect.TypeOf(target).Comparable()
|
|
||||||
for {
|
|
||||||
if isComparable && err == target {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// TODO: consider supporing target.Is(err). This would allow
|
|
||||||
// user-definable predicates, but also may allow for coping with sloppy
|
|
||||||
// APIs, thereby making it easier to get away with them.
|
|
||||||
if err = Unwrap(err); err == nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// As finds the first error in err's chain that matches the type to which target
|
|
||||||
// points, and if so, sets the target to its value and returns true. An error
|
|
||||||
// matches a type if it is assignable to the target type, or if it has a method
|
|
||||||
// As(interface{}) bool such that As(target) returns true. As will panic if target
|
|
||||||
// is not a non-nil pointer to a type which implements error or is of interface type.
|
|
||||||
//
|
|
||||||
// The As method should set the target to its value and return true if err
|
|
||||||
// matches the type to which target points.
|
|
||||||
func As(err error, target interface{}) bool {
|
|
||||||
if target == nil {
|
|
||||||
panic("errors: target cannot be nil")
|
|
||||||
}
|
|
||||||
val := reflect.ValueOf(target)
|
|
||||||
typ := val.Type()
|
|
||||||
if typ.Kind() != reflect.Ptr || val.IsNil() {
|
|
||||||
panic("errors: target must be a non-nil pointer")
|
|
||||||
}
|
|
||||||
if e := typ.Elem(); e.Kind() != reflect.Interface && !e.Implements(errorType) {
|
|
||||||
panic("errors: *target must be interface or implement error")
|
|
||||||
}
|
|
||||||
targetType := typ.Elem()
|
|
||||||
for err != nil {
|
|
||||||
if reflect.TypeOf(err).AssignableTo(targetType) {
|
|
||||||
val.Elem().Set(reflect.ValueOf(err))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
err = Unwrap(err)
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
var errorType = reflect.TypeOf((*error)(nil)).Elem()
|
|
8
vendor/modules.txt
vendored
8
vendor/modules.txt
vendored
|
@ -384,8 +384,8 @@ github.com/google/certificate-transparency-go/jsonclient
|
||||||
github.com/google/certificate-transparency-go/tls
|
github.com/google/certificate-transparency-go/tls
|
||||||
github.com/google/certificate-transparency-go/x509
|
github.com/google/certificate-transparency-go/x509
|
||||||
github.com/google/certificate-transparency-go/x509/pkix
|
github.com/google/certificate-transparency-go/x509/pkix
|
||||||
# github.com/google/go-cmp v0.5.7
|
# github.com/google/go-cmp v0.5.9
|
||||||
## explicit; go 1.11
|
## explicit; go 1.13
|
||||||
github.com/google/go-cmp/cmp
|
github.com/google/go-cmp/cmp
|
||||||
github.com/google/go-cmp/cmp/cmpopts
|
github.com/google/go-cmp/cmp/cmpopts
|
||||||
github.com/google/go-cmp/cmp/internal/diff
|
github.com/google/go-cmp/cmp/internal/diff
|
||||||
|
@ -975,10 +975,6 @@ golang.org/x/text/unicode/norm
|
||||||
# golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11
|
# golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11
|
||||||
## explicit
|
## explicit
|
||||||
golang.org/x/time/rate
|
golang.org/x/time/rate
|
||||||
# golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
|
|
||||||
## explicit; go 1.11
|
|
||||||
golang.org/x/xerrors
|
|
||||||
golang.org/x/xerrors/internal
|
|
||||||
# google.golang.org/api v0.54.0
|
# google.golang.org/api v0.54.0
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
google.golang.org/api/internal
|
google.golang.org/api/internal
|
||||||
|
|
Loading…
Reference in a new issue