diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-07-04 10:38:29 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-07-04 15:05:30 +0200 |
| commit | dcff124efb2ea4a834b74ac0974aa2f2fd000b40 (patch) | |
| tree | 8d49a1e0849baa283d09c7227ec9d2311a34258a /vendor/github.com | |
| parent | 4f739670f77d37168a44be2139f4005b748a825d (diff) | |
go.mod: switch to modules for dependency management
Godep is long deprecated and modules is the future.
Updating dependencies with godep is painful and non-transparent.
This will hopefully help to create custom golangci-lint linters.
The change was created with:
go mod init
rm -rf vendor
go mod vendor
Fixes #1247
Diffstat (limited to 'vendor/github.com')
40 files changed, 206 insertions, 2165 deletions
diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go deleted file mode 100644 index 41bbddc61..000000000 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/equate.go +++ /dev/null @@ -1,89 +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.md file. - -// Package cmpopts provides common options for the cmp package. -package cmpopts - -import ( - "math" - "reflect" - - "github.com/google/go-cmp/cmp" -) - -func equateAlways(_, _ interface{}) bool { return true } - -// 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. -func EquateEmpty() cmp.Option { - return cmp.FilterValues(isEmpty, cmp.Comparer(equateAlways)) -} - -func isEmpty(x, y interface{}) bool { - vx, vy := reflect.ValueOf(x), reflect.ValueOf(y) - return (x != nil && y != nil && vx.Type() == vy.Type()) && - (vx.Kind() == reflect.Slice || vx.Kind() == reflect.Map) && - (vx.Len() == 0 && vy.Len() == 0) -} - -// 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. -func EquateApprox(fraction, margin float64) cmp.Option { - if margin < 0 || fraction < 0 || math.IsNaN(margin) || math.IsNaN(fraction) { - panic("margin or fraction must be a non-negative number") - } - a := approximator{fraction, margin} - return cmp.Options{ - cmp.FilterValues(areRealF64s, cmp.Comparer(a.compareF64)), - cmp.FilterValues(areRealF32s, cmp.Comparer(a.compareF32)), - } -} - -type approximator struct{ frac, marg float64 } - -func areRealF64s(x, y float64) bool { - return !math.IsNaN(x) && !math.IsNaN(y) && !math.IsInf(x, 0) && !math.IsInf(y, 0) -} -func areRealF32s(x, y float32) bool { - return areRealF64s(float64(x), float64(y)) -} -func (a approximator) compareF64(x, y float64) bool { - relMarg := a.frac * math.Min(math.Abs(x), math.Abs(y)) - return math.Abs(x-y) <= math.Max(a.marg, relMarg) -} -func (a approximator) compareF32(x, y float32) bool { - return a.compareF64(float64(x), float64(y)) -} - -// EquateNaNs returns a Comparer option that determines float32 and float64 -// NaN values to be equal. -// -// EquateNaNs can be used in conjunction with EquateApprox. -func EquateNaNs() cmp.Option { - return cmp.Options{ - cmp.FilterValues(areNaNsF64s, cmp.Comparer(equateAlways)), - cmp.FilterValues(areNaNsF32s, cmp.Comparer(equateAlways)), - } -} - -func areNaNsF64s(x, y float64) bool { - return math.IsNaN(x) && math.IsNaN(y) -} -func areNaNsF32s(x, y float32) bool { - return areNaNsF64s(float64(x), float64(y)) -} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go deleted file mode 100644 index ff8e785d4..000000000 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/ignore.go +++ /dev/null @@ -1,207 +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.md file. - -package cmpopts - -import ( - "fmt" - "reflect" - "unicode" - "unicode/utf8" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/internal/function" -) - -// IgnoreFields returns an Option that ignores exported fields of the -// given names on a single struct type. -// The struct type is specified by passing in a value of that type. -// -// The name may be a dot-delimited string (e.g., "Foo.Bar") to ignore a -// specific sub-field that is embedded or nested within the parent struct. -// -// This does not handle unexported fields; use IgnoreUnexported instead. -func IgnoreFields(typ interface{}, names ...string) cmp.Option { - sf := newStructFilter(typ, names...) - return cmp.FilterPath(sf.filter, cmp.Ignore()) -} - -// IgnoreTypes returns an Option that ignores all values assignable to -// certain types, which are specified by passing in a value of each type. -func IgnoreTypes(typs ...interface{}) cmp.Option { - tf := newTypeFilter(typs...) - return cmp.FilterPath(tf.filter, cmp.Ignore()) -} - -type typeFilter []reflect.Type - -func newTypeFilter(typs ...interface{}) (tf typeFilter) { - for _, typ := range typs { - t := reflect.TypeOf(typ) - if t == nil { - // This occurs if someone tries to pass in sync.Locker(nil) - panic("cannot determine type; consider using IgnoreInterfaces") - } - tf = append(tf, t) - } - return tf -} -func (tf typeFilter) filter(p cmp.Path) bool { - if len(p) < 1 { - return false - } - t := p.Last().Type() - for _, ti := range tf { - if t.AssignableTo(ti) { - return true - } - } - return false -} - -// IgnoreInterfaces returns an Option that ignores all values or references of -// values assignable to certain interface types. These interfaces are specified -// by passing in an anonymous struct with the interface types embedded in it. -// For example, to ignore sync.Locker, pass in struct{sync.Locker}{}. -func IgnoreInterfaces(ifaces interface{}) cmp.Option { - tf := newIfaceFilter(ifaces) - return cmp.FilterPath(tf.filter, cmp.Ignore()) -} - -type ifaceFilter []reflect.Type - -func newIfaceFilter(ifaces interface{}) (tf ifaceFilter) { - t := reflect.TypeOf(ifaces) - if ifaces == nil || t.Name() != "" || t.Kind() != reflect.Struct { - panic("input must be an anonymous struct") - } - for i := 0; i < t.NumField(); i++ { - fi := t.Field(i) - switch { - case !fi.Anonymous: - panic("struct cannot have named fields") - case fi.Type.Kind() != reflect.Interface: - panic("embedded field must be an interface type") - case fi.Type.NumMethod() == 0: - // This matches everything; why would you ever want this? - panic("cannot ignore empty interface") - default: - tf = append(tf, fi.Type) - } - } - return tf -} -func (tf ifaceFilter) filter(p cmp.Path) bool { - if len(p) < 1 { - return false - } - t := p.Last().Type() - for _, ti := range tf { - if t.AssignableTo(ti) { - return true - } - if t.Kind() != reflect.Ptr && reflect.PtrTo(t).AssignableTo(ti) { - return true - } - } - return false -} - -// IgnoreUnexported returns an Option that only ignores the immediate unexported -// fields of a struct, including anonymous fields of unexported types. -// In particular, unexported fields within the struct's exported fields -// of struct types, including anonymous fields, will not be ignored unless the -// type of the field itself is also passed to IgnoreUnexported. -// -// Avoid ignoring unexported fields of a type which you do not control (i.e. a -// type from another repository), as changes to the implementation of such types -// may change how the comparison behaves. Prefer a custom Comparer instead. -func IgnoreUnexported(typs ...interface{}) cmp.Option { - ux := newUnexportedFilter(typs...) - return cmp.FilterPath(ux.filter, cmp.Ignore()) -} - -type unexportedFilter struct{ m map[reflect.Type]bool } - -func newUnexportedFilter(typs ...interface{}) unexportedFilter { - ux := unexportedFilter{m: make(map[reflect.Type]bool)} - for _, typ := range typs { - t := reflect.TypeOf(typ) - if t == nil || t.Kind() != reflect.Struct { - panic(fmt.Sprintf("invalid struct type: %T", typ)) - } - ux.m[t] = true - } - return ux -} -func (xf unexportedFilter) filter(p cmp.Path) bool { - sf, ok := p.Index(-1).(cmp.StructField) - if !ok { - return false - } - return xf.m[p.Index(-2).Type()] && !isExported(sf.Name()) -} - -// isExported reports whether the identifier is exported. -func isExported(id string) bool { - r, _ := utf8.DecodeRuneInString(id) - return unicode.IsUpper(r) -} - -// IgnoreSliceElements returns an Option that ignores elements of []V. -// The discard function must be of the form "func(T) bool" which is used to -// ignore slice elements of type V, where V is assignable to T. -// Elements are ignored if the function reports true. -func IgnoreSliceElements(discardFunc interface{}) cmp.Option { - vf := reflect.ValueOf(discardFunc) - if !function.IsType(vf.Type(), function.ValuePredicate) || vf.IsNil() { - panic(fmt.Sprintf("invalid discard function: %T", discardFunc)) - } - return cmp.FilterPath(func(p cmp.Path) bool { - si, ok := p.Index(-1).(cmp.SliceIndex) - if !ok { - return false - } - if !si.Type().AssignableTo(vf.Type().In(0)) { - return false - } - vx, vy := si.Values() - if vx.IsValid() && vf.Call([]reflect.Value{vx})[0].Bool() { - return true - } - if vy.IsValid() && vf.Call([]reflect.Value{vy})[0].Bool() { - return true - } - return false - }, cmp.Ignore()) -} - -// IgnoreMapEntries returns an Option that ignores entries of map[K]V. -// The discard function must be of the form "func(T, R) bool" which is used to -// ignore map entries of type K and V, where K and V are assignable to T and R. -// Entries are ignored if the function reports true. -func IgnoreMapEntries(discardFunc interface{}) cmp.Option { - vf := reflect.ValueOf(discardFunc) - if !function.IsType(vf.Type(), function.KeyValuePredicate) || vf.IsNil() { - panic(fmt.Sprintf("invalid discard function: %T", discardFunc)) - } - return cmp.FilterPath(func(p cmp.Path) bool { - mi, ok := p.Index(-1).(cmp.MapIndex) - if !ok { - return false - } - if !mi.Key().Type().AssignableTo(vf.Type().In(0)) || !mi.Type().AssignableTo(vf.Type().In(1)) { - return false - } - k := mi.Key() - vx, vy := mi.Values() - if vx.IsValid() && vf.Call([]reflect.Value{k, vx})[0].Bool() { - return true - } - if vy.IsValid() && vf.Call([]reflect.Value{k, vy})[0].Bool() { - return true - } - return false - }, cmp.Ignore()) -} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go deleted file mode 100644 index 3a4804621..000000000 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/sort.go +++ /dev/null @@ -1,147 +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.md file. - -package cmpopts - -import ( - "fmt" - "reflect" - "sort" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/internal/function" -) - -// SortSlices returns a Transformer option that sorts all []V. -// The less function must be of the form "func(T, T) bool" which is used to -// sort any slice with element type V that is assignable to T. -// -// The less function must be: -// • Deterministic: less(x, y) == less(x, y) -// • Irreflexive: !less(x, x) -// • 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 -// !less(y, x) for two elements x and y, their relative order is maintained. -// -// SortSlices can be used in conjunction with EquateEmpty. -func SortSlices(lessFunc interface{}) cmp.Option { - vf := reflect.ValueOf(lessFunc) - if !function.IsType(vf.Type(), function.Less) || vf.IsNil() { - panic(fmt.Sprintf("invalid less function: %T", lessFunc)) - } - ss := sliceSorter{vf.Type().In(0), vf} - return cmp.FilterValues(ss.filter, cmp.Transformer("cmpopts.SortSlices", ss.sort)) -} - -type sliceSorter struct { - in reflect.Type // T - fnc reflect.Value // func(T, T) bool -} - -func (ss sliceSorter) filter(x, y interface{}) bool { - vx, vy := reflect.ValueOf(x), reflect.ValueOf(y) - if !(x != nil && y != nil && vx.Type() == vy.Type()) || - !(vx.Kind() == reflect.Slice && vx.Type().Elem().AssignableTo(ss.in)) || - (vx.Len() <= 1 && vy.Len() <= 1) { - return false - } - // Check whether the slices are already sorted to avoid an infinite - // recursion cycle applying the same transform to itself. - ok1 := sort.SliceIsSorted(x, func(i, j int) bool { return ss.less(vx, i, j) }) - ok2 := sort.SliceIsSorted(y, func(i, j int) bool { return ss.less(vy, i, j) }) - return !ok1 || !ok2 -} -func (ss sliceSorter) sort(x interface{}) interface{} { - src := reflect.ValueOf(x) - dst := reflect.MakeSlice(src.Type(), src.Len(), src.Len()) - for i := 0; i < src.Len(); i++ { - dst.Index(i).Set(src.Index(i)) - } - sort.SliceStable(dst.Interface(), func(i, j int) bool { return ss.less(dst, i, j) }) - ss.checkSort(dst) - return dst.Interface() -} -func (ss sliceSorter) checkSort(v reflect.Value) { - start := -1 // Start of a sequence of equal elements. - for i := 1; i < v.Len(); i++ { - if ss.less(v, i-1, i) { - // Check that first and last elements in v[start:i] are equal. - if start >= 0 && (ss.less(v, start, i-1) || ss.less(v, i-1, start)) { - panic(fmt.Sprintf("incomparable values detected: want equal elements: %v", v.Slice(start, i))) - } - start = -1 - } else if start == -1 { - start = i - } - } -} -func (ss sliceSorter) less(v reflect.Value, i, j int) bool { - vx, vy := v.Index(i), v.Index(j) - return ss.fnc.Call([]reflect.Value{vx, vy})[0].Bool() -} - -// SortMaps returns a Transformer option that flattens map[K]V types to be a -// sorted []struct{K, V}. The less function must be of the form -// "func(T, T) bool" which is used to sort any map with key K that is -// assignable to T. -// -// Flattening the map into a slice has the property that cmp.Equal is able to -// use Comparers on K or the K.Equal method if it exists. -// -// The less function must be: -// • Deterministic: less(x, y) == less(x, y) -// • Irreflexive: !less(x, x) -// • 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) -// -// SortMaps can be used in conjunction with EquateEmpty. -func SortMaps(lessFunc interface{}) cmp.Option { - vf := reflect.ValueOf(lessFunc) - if !function.IsType(vf.Type(), function.Less) || vf.IsNil() { - panic(fmt.Sprintf("invalid less function: %T", lessFunc)) - } - ms := mapSorter{vf.Type().In(0), vf} - return cmp.FilterValues(ms.filter, cmp.Transformer("cmpopts.SortMaps", ms.sort)) -} - -type mapSorter struct { - in reflect.Type // T - fnc reflect.Value // func(T, T) bool -} - -func (ms mapSorter) filter(x, y interface{}) bool { - vx, vy := reflect.ValueOf(x), reflect.ValueOf(y) - return (x != nil && y != nil && vx.Type() == vy.Type()) && - (vx.Kind() == reflect.Map && vx.Type().Key().AssignableTo(ms.in)) && - (vx.Len() != 0 || vy.Len() != 0) -} -func (ms mapSorter) sort(x interface{}) interface{} { - src := reflect.ValueOf(x) - outType := reflect.StructOf([]reflect.StructField{ - {Name: "K", Type: src.Type().Key()}, - {Name: "V", Type: src.Type().Elem()}, - }) - dst := reflect.MakeSlice(reflect.SliceOf(outType), src.Len(), src.Len()) - for i, k := range src.MapKeys() { - v := reflect.New(outType).Elem() - v.Field(0).Set(k) - v.Field(1).Set(src.MapIndex(k)) - dst.Index(i).Set(v) - } - sort.Slice(dst.Interface(), func(i, j int) bool { return ms.less(dst, i, j) }) - ms.checkSort(dst) - return dst.Interface() -} -func (ms mapSorter) checkSort(v reflect.Value) { - for i := 1; i < v.Len(); i++ { - if !ms.less(v, i-1, i) { - panic(fmt.Sprintf("partial order detected: want %v < %v", v.Index(i-1), v.Index(i))) - } - } -} -func (ms mapSorter) less(v reflect.Value, i, j int) bool { - vx, vy := v.Index(i).Field(0), v.Index(j).Field(0) - return ms.fnc.Call([]reflect.Value{vx, vy})[0].Bool() -} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go deleted file mode 100644 index 97f707983..000000000 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/struct_filter.go +++ /dev/null @@ -1,182 +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.md file. - -package cmpopts - -import ( - "fmt" - "reflect" - "strings" - - "github.com/google/go-cmp/cmp" -) - -// filterField returns a new Option where opt is only evaluated on paths that -// include a specific exported field on a single struct type. -// The struct type is specified by passing in a value of that type. -// -// The name may be a dot-delimited string (e.g., "Foo.Bar") to select a -// specific sub-field that is embedded or nested within the parent struct. -func filterField(typ interface{}, name string, opt cmp.Option) cmp.Option { - // TODO: This is currently unexported over concerns of how helper filters - // can be composed together easily. - // TODO: Add tests for FilterField. - - sf := newStructFilter(typ, name) - return cmp.FilterPath(sf.filter, opt) -} - -type structFilter struct { - t reflect.Type // The root struct type to match on - ft fieldTree // Tree of fields to match on -} - -func newStructFilter(typ interface{}, names ...string) structFilter { - // TODO: Perhaps allow * as a special identifier to allow ignoring any - // number of path steps until the next field match? - // This could be useful when a concrete struct gets transformed into - // an anonymous struct where it is not possible to specify that by type, - // but the transformer happens to provide guarantees about the names of - // the transformed fields. - - t := reflect.TypeOf(typ) - if t == nil || t.Kind() != reflect.Struct { - panic(fmt.Sprintf("%T must be a struct", typ)) - } - var ft fieldTree - for _, name := range names { - cname, err := canonicalName(t, name) - if err != nil { - panic(fmt.Sprintf("%s: %v", strings.Join(cname, "."), err)) - } - ft.insert(cname) - } - return structFilter{t, ft} -} - -func (sf structFilter) filter(p cmp.Path) bool { - for i, ps := range p { - if ps.Type().AssignableTo(sf.t) && sf.ft.matchPrefix(p[i+1:]) { - return true - } - } - return false -} - -// fieldTree represents a set of dot-separated identifiers. -// -// For example, inserting the following selectors: -// Foo -// Foo.Bar.Baz -// Foo.Buzz -// Nuka.Cola.Quantum -// -// Results in a tree of the form: -// {sub: { -// "Foo": {ok: true, sub: { -// "Bar": {sub: { -// "Baz": {ok: true}, -// }}, -// "Buzz": {ok: true}, -// }}, -// "Nuka": {sub: { -// "Cola": {sub: { -// "Quantum": {ok: true}, -// }}, -// }}, -// }} -type fieldTree struct { - ok bool // Whether this is a specified node - sub map[string]fieldTree // The sub-tree of fields under this node -} - -// insert inserts a sequence of field accesses into the tree. -func (ft *fieldTree) insert(cname []string) { - if ft.sub == nil { - ft.sub = make(map[string]fieldTree) - } - if len(cname) == 0 { - ft.ok = true - return - } - sub := ft.sub[cname[0]] - sub.insert(cname[1:]) - ft.sub[cname[0]] = sub -} - -// matchPrefix reports whether any selector in the fieldTree matches -// the start of path p. -func (ft fieldTree) matchPrefix(p cmp.Path) bool { - for _, ps := range p { - switch ps := ps.(type) { - case cmp.StructField: - ft = ft.sub[ps.Name()] - if ft.ok { - return true - } - if len(ft.sub) == 0 { - return false - } - case cmp.Indirect: - default: - return false - } - } - return false -} - -// canonicalName returns a list of identifiers where any struct field access -// through an embedded field is expanded to include the names of the embedded -// types themselves. -// -// For example, suppose field "Foo" is not directly in the parent struct, -// but actually from an embedded struct of type "Bar". Then, the canonical name -// of "Foo" is actually "Bar.Foo". -// -// Suppose field "Foo" is not directly in the parent struct, but actually -// a field in two different embedded structs of types "Bar" and "Baz". -// Then the selector "Foo" causes a panic since it is ambiguous which one it -// refers to. The user must specify either "Bar.Foo" or "Baz.Foo". -func canonicalName(t reflect.Type, sel string) ([]string, error) { - var name string - sel = strings.TrimPrefix(sel, ".") - if sel == "" { - return nil, fmt.Errorf("name must not be empty") - } - if i := strings.IndexByte(sel, '.'); i < 0 { - name, sel = sel, "" - } else { - name, sel = sel[:i], sel[i:] - } - - // Type must be a struct or pointer to struct. - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - if t.Kind() != reflect.Struct { - return nil, fmt.Errorf("%v must be a struct", t) - } - - // Find the canonical name for this current field name. - // If the field exists in an embedded struct, then it will be expanded. - if !isExported(name) { - // Disallow unexported fields: - // * To discourage people from actually touching unexported fields - // * FieldByName is buggy (https://golang.org/issue/4876) - return []string{name}, fmt.Errorf("name must be exported") - } - sf, ok := t.FieldByName(name) - if !ok { - return []string{name}, fmt.Errorf("does not exist") - } - var ss []string - for i := range sf.Index { - ss = append(ss, t.FieldByIndex(sf.Index[:i+1]).Name) - } - if sel == "" { - return ss, nil - } - ssPost, err := canonicalName(sf.Type, sel) - return append(ss, ssPost...), err -} diff --git a/vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go b/vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go deleted file mode 100644 index 9d651553d..000000000 --- a/vendor/github.com/google/go-cmp/cmp/cmpopts/xform.go +++ /dev/null @@ -1,35 +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.md file. - -package cmpopts - -import ( - "github.com/google/go-cmp/cmp" -) - -type xformFilter struct{ xform cmp.Option } - -func (xf xformFilter) filter(p cmp.Path) bool { - for _, ps := range p { - if t, ok := ps.(cmp.Transform); ok && t.Option() == xf.xform { - return false - } - } - return true -} - -// AcyclicTransformer returns a Transformer with a filter applied that ensures -// that the transformer cannot be recursively applied upon its own output. -// -// An example use case is a transformer that splits a string by lines: -// AcyclicTransformer("SplitLines", func(s string) []string{ -// return strings.Split(s, "\n") -// }) -// -// Had this been an unfiltered Transformer instead, this would result in an -// infinite cycle converting a string to []string to [][]string and so on. -func AcyclicTransformer(name string, xformFunc interface{}) cmp.Option { - xf := xformFilter{cmp.Transformer(name, xformFunc)} - return cmp.FilterPath(xf.filter, xf.xform) -} diff --git a/vendor/github.com/google/go-cmp/cmp/compare.go b/vendor/github.com/google/go-cmp/cmp/compare.go index 2133562b0..c9a63ceda 100644 --- a/vendor/github.com/google/go-cmp/cmp/compare.go +++ b/vendor/github.com/google/go-cmp/cmp/compare.go @@ -22,8 +22,8 @@ // equality is determined by recursively comparing the primitive kinds on both // values, much like reflect.DeepEqual. Unlike reflect.DeepEqual, unexported // fields are not compared by default; they result in panics unless suppressed -// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly compared -// using the AllowUnexported option. +// by using an Ignore option (see cmpopts.IgnoreUnexported) or explicitly +// compared using the Exporter option. package cmp import ( @@ -62,8 +62,8 @@ import ( // // Structs are equal if recursively calling Equal on all fields report equal. // If a struct contains unexported fields, Equal panics unless an Ignore option -// (e.g., cmpopts.IgnoreUnexported) ignores that field or the AllowUnexported -// option explicitly permits comparing the unexported field. +// (e.g., cmpopts.IgnoreUnexported) ignores that field or the Exporter option +// explicitly permits comparing the unexported field. // // Slices are equal if they are both nil or both non-nil, where recursively // calling Equal on all non-ignored slice or array elements report equal. @@ -80,6 +80,11 @@ import ( // Pointers and interfaces are equal if they are both nil or both non-nil, // where they have the same underlying concrete type and recursively // calling Equal on the underlying values reports equal. +// +// Before recursing into a pointer, slice element, or map, the current path +// is checked to detect whether the address has already been visited. +// If there is a cycle, then the pointed at values are considered equal +// only if both addresses were previously visited in the same path step. func Equal(x, y interface{}, opts ...Option) bool { vx := reflect.ValueOf(x) vy := reflect.ValueOf(y) @@ -137,6 +142,7 @@ type state struct { // Calling statelessCompare must not result in observable changes to these. result diff.Result // The current result of comparison curPath Path // The current path in the value tree + curPtrs pointerPath // The current set of visited pointers reporters []reporter // Optional reporters // recChecker checks for infinite cycles applying the same set of @@ -148,13 +154,14 @@ type state struct { dynChecker dynChecker // These fields, once set by processOption, will not change. - exporters map[reflect.Type]bool // Set of structs with unexported field visibility - opts Options // List of all fundamental and filter options + exporters []exporter // List of exporters for structs with unexported fields + opts Options // List of all fundamental and filter options } func newState(opts []Option) *state { // Always ensure a validator option exists to validate the inputs. s := &state{opts: Options{validator{}}} + s.curPtrs.Init() s.processOption(Options(opts)) return s } @@ -174,13 +181,8 @@ func (s *state) processOption(opt Option) { panic(fmt.Sprintf("cannot use an unfiltered option: %v", opt)) } s.opts = append(s.opts, opt) - case visibleStructs: - if s.exporters == nil { - s.exporters = make(map[reflect.Type]bool) - } - for t := range opt { - s.exporters[t] = true - } + case exporter: + s.exporters = append(s.exporters, opt) case reporter: s.reporters = append(s.reporters, opt) default: @@ -192,9 +194,9 @@ func (s *state) processOption(opt Option) { // This function is stateless in that it does not alter the current result, // or output to any registered reporters. func (s *state) statelessCompare(step PathStep) diff.Result { - // We do not save and restore the curPath because all of the compareX - // methods should properly push and pop from the path. - // It is an implementation bug if the contents of curPath differs from + // We do not save and restore curPath and curPtrs because all of the + // compareX methods should properly push and pop from them. + // It is an implementation bug if the contents of the paths differ from // when calling this function to when returning from it. oldResult, oldReporters := s.result, s.reporters @@ -216,9 +218,17 @@ func (s *state) compareAny(step PathStep) { } s.recChecker.Check(s.curPath) - // Obtain the current type and values. + // Cycle-detection for slice elements (see NOTE in compareSlice). t := step.Type() vx, vy := step.Values() + if si, ok := step.(SliceIndex); ok && si.isSlice && vx.IsValid() && vy.IsValid() { + px, py := vx.Addr(), vy.Addr() + if eq, visited := s.curPtrs.Push(px, py); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(px, py) + } // Rule 1: Check whether an option applies on this node in the value tree. if s.tryOptions(t, vx, vy) { @@ -354,6 +364,7 @@ func sanitizeValue(v reflect.Value, t reflect.Type) reflect.Value { func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) { var vax, vay reflect.Value // Addressable versions of vx and vy + var mayForce, mayForceInit bool step := StructField{&structField{}} for i := 0; i < t.NumField(); i++ { step.typ = t.Field(i).Type @@ -375,7 +386,13 @@ func (s *state) compareStruct(t reflect.Type, vx, vy reflect.Value) { vax = makeAddressable(vx) vay = makeAddressable(vy) } - step.mayForce = s.exporters[t] + if !mayForceInit { + for _, xf := range s.exporters { + mayForce = mayForce || xf(t) + } + mayForceInit = true + } + step.mayForce = mayForce step.pvx = vax step.pvy = vay step.field = t.Field(i) @@ -391,9 +408,21 @@ func (s *state) compareSlice(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // NOTE: It is incorrect to call curPtrs.Push on the slice header pointer + // since slices represents a list of pointers, rather than a single pointer. + // The pointer checking logic must be handled on a per-element basis + // in compareAny. + // + // A slice header (see reflect.SliceHeader) in Go is a tuple of a starting + // pointer P, a length N, and a capacity C. Supposing each slice element has + // a memory size of M, then the slice is equivalent to the list of pointers: + // [P+i*M for i in range(N)] + // + // For example, v[:0] and v[:1] are slices with the same starting pointer, + // but they are clearly different values. Using the slice pointer alone + // violates the assumption that equal pointers implies equal values. - step := SliceIndex{&sliceIndex{pathStep: pathStep{typ: t.Elem()}}} + step := SliceIndex{&sliceIndex{pathStep: pathStep{typ: t.Elem()}, isSlice: isSlice}} withIndexes := func(ix, iy int) SliceIndex { if ix >= 0 { step.vx, step.xkey = vx.Index(ix), ix @@ -470,7 +499,12 @@ func (s *state) compareMap(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // Cycle-detection for maps. + if eq, visited := s.curPtrs.Push(vx, vy); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(vx, vy) // We combine and sort the two map keys so that we can perform the // comparisons in a deterministic order. @@ -507,7 +541,12 @@ func (s *state) comparePtr(t reflect.Type, vx, vy reflect.Value) { return } - // TODO: Support cyclic data structures. + // Cycle-detection for pointers. + if eq, visited := s.curPtrs.Push(vx, vy); visited { + s.report(eq, reportByCycle) + return + } + defer s.curPtrs.Pop(vx, vy) vx, vy = vx.Elem(), vy.Elem() s.compareAny(Indirect{&indirect{pathStep{t.Elem(), vx, vy}}}) diff --git a/vendor/github.com/google/go-cmp/cmp/export_panic.go b/vendor/github.com/google/go-cmp/cmp/export_panic.go index abc3a1c3e..dd032354f 100644 --- a/vendor/github.com/google/go-cmp/cmp/export_panic.go +++ b/vendor/github.com/google/go-cmp/cmp/export_panic.go @@ -8,8 +8,8 @@ package cmp import "reflect" -const supportAllowUnexported = false +const supportExporters = false func retrieveUnexportedField(reflect.Value, reflect.StructField) reflect.Value { - panic("retrieveUnexportedField is not implemented") + panic("no support for forcibly accessing unexported fields") } diff --git a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go b/vendor/github.com/google/go-cmp/cmp/export_unsafe.go index 59d4ee91b..57020e26c 100644 --- a/vendor/github.com/google/go-cmp/cmp/export_unsafe.go +++ b/vendor/github.com/google/go-cmp/cmp/export_unsafe.go @@ -11,7 +11,7 @@ import ( "unsafe" ) -const supportAllowUnexported = true +const supportExporters = true // retrieveUnexportedField uses unsafe to forcibly retrieve any field from // a struct such that the value has read-write permissions. @@ -19,5 +19,7 @@ const supportAllowUnexported = true // The parent struct, v, must be addressable, while f must be a StructField // describing the field to retrieve. func retrieveUnexportedField(v reflect.Value, f reflect.StructField) reflect.Value { - return reflect.NewAt(f.Type, unsafe.Pointer(v.UnsafeAddr()+f.Offset)).Elem() + // See https://github.com/google/go-cmp/issues/167 for discussion of the + // following expression. + return reflect.NewAt(f.Type, unsafe.Pointer(uintptr(unsafe.Pointer(v.UnsafeAddr()))+f.Offset)).Elem() } diff --git a/vendor/github.com/google/go-cmp/cmp/internal/testprotos/protos.go b/vendor/github.com/google/go-cmp/cmp/internal/testprotos/protos.go deleted file mode 100644 index 120c8b0e8..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/testprotos/protos.go +++ /dev/null @@ -1,116 +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.md file. - -package testprotos - -func Equal(x, y Message) bool { - if x == nil || y == nil { - return x == nil && y == nil - } - return x.String() == y.String() -} - -type Message interface { - Proto() - String() string -} - -type proto interface { - Proto() -} - -type notComparable struct { - unexportedField func() -} - -type Stringer struct{ X string } - -func (s *Stringer) String() string { return s.X } - -// Project1 protocol buffers -type ( - Eagle_States int - Eagle_MissingCalls int - Dreamer_States int - Dreamer_MissingCalls int - Slap_States int - Goat_States int - Donkey_States int - SummerType int - - Eagle struct { - proto - notComparable - Stringer - } - Dreamer struct { - proto - notComparable - Stringer - } - Slap struct { - proto - notComparable - Stringer - } - Goat struct { - proto - notComparable - Stringer - } - Donkey struct { - proto - notComparable - Stringer - } -) - -// Project2 protocol buffers -type ( - Germ struct { - proto - notComparable - Stringer - } - Dish struct { - proto - notComparable - Stringer - } -) - -// Project3 protocol buffers -type ( - Dirt struct { - proto - notComparable - Stringer - } - Wizard struct { - proto - notComparable - Stringer - } - Sadistic struct { - proto - notComparable - Stringer - } -) - -// Project4 protocol buffers -type ( - HoneyStatus int - PoisonType int - MetaData struct { - proto - notComparable - Stringer - } - Restrictions struct { - proto - notComparable - Stringer - } -) diff --git a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project1.go b/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project1.go deleted file mode 100644 index 1999e38fd..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project1.go +++ /dev/null @@ -1,267 +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.md file. - -package teststructs - -import ( - "time" - - pb "github.com/google/go-cmp/cmp/internal/testprotos" -) - -// This is an sanitized example of equality from a real use-case. -// The original equality function was as follows: -/* -func equalEagle(x, y Eagle) bool { - if x.Name != y.Name && - !reflect.DeepEqual(x.Hounds, y.Hounds) && - x.Desc != y.Desc && - x.DescLong != y.DescLong && - x.Prong != y.Prong && - x.StateGoverner != y.StateGoverner && - x.PrankRating != y.PrankRating && - x.FunnyPrank != y.FunnyPrank && - !pb.Equal(x.Immutable.Proto(), y.Immutable.Proto()) { - return false - } - - if len(x.Dreamers) != len(y.Dreamers) { - return false - } - for i := range x.Dreamers { - if !equalDreamer(x.Dreamers[i], y.Dreamers[i]) { - return false - } - } - if len(x.Slaps) != len(y.Slaps) { - return false - } - for i := range x.Slaps { - if !equalSlap(x.Slaps[i], y.Slaps[i]) { - return false - } - } - return true -} -func equalDreamer(x, y Dreamer) bool { - if x.Name != y.Name || - x.Desc != y.Desc || - x.DescLong != y.DescLong || - x.ContSlapsInterval != y.ContSlapsInterval || - x.Ornamental != y.Ornamental || - x.Amoeba != y.Amoeba || - x.Heroes != y.Heroes || - x.FloppyDisk != y.FloppyDisk || - x.MightiestDuck != y.MightiestDuck || - x.FunnyPrank != y.FunnyPrank || - !pb.Equal(x.Immutable.Proto(), y.Immutable.Proto()) { - - return false - } - if len(x.Animal) != len(y.Animal) { - return false - } - for i := range x.Animal { - vx := x.Animal[i] - vy := y.Animal[i] - if reflect.TypeOf(x.Animal) != reflect.TypeOf(y.Animal) { - return false - } - switch vx.(type) { - case Goat: - if !equalGoat(vx.(Goat), vy.(Goat)) { - return false - } - case Donkey: - if !equalDonkey(vx.(Donkey), vy.(Donkey)) { - return false - } - default: - panic(fmt.Sprintf("unknown type: %T", vx)) - } - } - if len(x.PreSlaps) != len(y.PreSlaps) { - return false - } - for i := range x.PreSlaps { - if !equalSlap(x.PreSlaps[i], y.PreSlaps[i]) { - return false - } - } - if len(x.ContSlaps) != len(y.ContSlaps) { - return false - } - for i := range x.ContSlaps { - if !equalSlap(x.ContSlaps[i], y.ContSlaps[i]) { - return false - } - } - return true -} -func equalSlap(x, y Slap) bool { - return x.Name == y.Name && - x.Desc == y.Desc && - x.DescLong == y.DescLong && - pb.Equal(x.Args, y.Args) && - x.Tense == y.Tense && - x.Interval == y.Interval && - x.Homeland == y.Homeland && - x.FunnyPrank == y.FunnyPrank && - pb.Equal(x.Immutable.Proto(), y.Immutable.Proto()) -} -func equalGoat(x, y Goat) bool { - if x.Target != y.Target || - x.FunnyPrank != y.FunnyPrank || - !pb.Equal(x.Immutable.Proto(), y.Immutable.Proto()) { - return false - } - if len(x.Slaps) != len(y.Slaps) { - return false - } - for i := range x.Slaps { - if !equalSlap(x.Slaps[i], y.Slaps[i]) { - return false - } - } - return true -} -func equalDonkey(x, y Donkey) bool { - return x.Pause == y.Pause && - x.Sleep == y.Sleep && - x.FunnyPrank == y.FunnyPrank && - pb.Equal(x.Immutable.Proto(), y.Immutable.Proto()) -} -*/ - -type Eagle struct { - Name string - Hounds []string - Desc string - DescLong string - Dreamers []Dreamer - Prong int64 - Slaps []Slap - StateGoverner string - PrankRating string - FunnyPrank string - Immutable *EagleImmutable -} - -type EagleImmutable struct { - ID string - State *pb.Eagle_States - MissingCall *pb.Eagle_MissingCalls - Birthday time.Time - Death time.Time - Started time.Time - LastUpdate time.Time - Creator string - empty bool -} - -type Dreamer struct { - Name string - Desc string - DescLong string - PreSlaps []Slap - ContSlaps []Slap - ContSlapsInterval int32 - Animal []interface{} // Could be either Goat or Donkey - Ornamental bool - Amoeba int64 - Heroes int32 - FloppyDisk int32 - MightiestDuck bool - FunnyPrank string - Immutable *DreamerImmutable -} - -type DreamerImmutable struct { - ID string - State *pb.Dreamer_States - MissingCall *pb.Dreamer_MissingCalls - Calls int32 - Started time.Time - Stopped time.Time - LastUpdate time.Time - empty bool -} - -type Slap struct { - Name string - Desc string - DescLong string - Args pb.Message - Tense int32 - Interval int32 - Homeland uint32 - FunnyPrank string - Immutable *SlapImmutable -} - -type SlapImmutable struct { - ID string - Out pb.Message - MildSlap bool - PrettyPrint string - State *pb.Slap_States - Started time.Time - Stopped time.Time - LastUpdate time.Time - LoveRadius *LoveRadius - empty bool -} - -type Goat struct { - Target string - Slaps []Slap - FunnyPrank string - Immutable *GoatImmutable -} - -type GoatImmutable struct { - ID string - State *pb.Goat_States - Started time.Time - Stopped time.Time - LastUpdate time.Time - empty bool -} -type Donkey struct { - Pause bool - Sleep int32 - FunnyPrank string - Immutable *DonkeyImmutable -} - -type DonkeyImmutable struct { - ID string - State *pb.Donkey_States - Started time.Time - Stopped time.Time - LastUpdate time.Time - empty bool -} - -type LoveRadius struct { - Summer *SummerLove - empty bool -} - -type SummerLove struct { - Summary *SummerLoveSummary - empty bool -} - -type SummerLoveSummary struct { - Devices []string - ChangeType []pb.SummerType - empty bool -} - -func (EagleImmutable) Proto() *pb.Eagle { return nil } -func (DreamerImmutable) Proto() *pb.Dreamer { return nil } -func (SlapImmutable) Proto() *pb.Slap { return nil } -func (GoatImmutable) Proto() *pb.Goat { return nil } -func (DonkeyImmutable) Proto() *pb.Donkey { return nil } diff --git a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project2.go b/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project2.go deleted file mode 100644 index 536592bbe..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project2.go +++ /dev/null @@ -1,74 +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.md file. - -package teststructs - -import ( - "time" - - pb "github.com/google/go-cmp/cmp/internal/testprotos" -) - -// This is an sanitized example of equality from a real use-case. -// The original equality function was as follows: -/* -func equalBatch(b1, b2 *GermBatch) bool { - for _, b := range []*GermBatch{b1, b2} { - for _, l := range b.DirtyGerms { - sort.Slice(l, func(i, j int) bool { return l[i].String() < l[j].String() }) - } - for _, l := range b.CleanGerms { - sort.Slice(l, func(i, j int) bool { return l[i].String() < l[j].String() }) - } - } - if !pb.DeepEqual(b1.DirtyGerms, b2.DirtyGerms) || - !pb.DeepEqual(b1.CleanGerms, b2.CleanGerms) || - !pb.DeepEqual(b1.GermMap, b2.GermMap) { - return false - } - if len(b1.DishMap) != len(b2.DishMap) { - return false - } - for id := range b1.DishMap { - kpb1, err1 := b1.DishMap[id].Proto() - kpb2, err2 := b2.DishMap[id].Proto() - if !pb.Equal(kpb1, kpb2) || !reflect.DeepEqual(err1, err2) { - return false - } - } - return b1.HasPreviousResult == b2.HasPreviousResult && - b1.DirtyID == b2.DirtyID && - b1.CleanID == b2.CleanID && - b1.GermStrain == b2.GermStrain && - b1.TotalDirtyGerms == b2.TotalDirtyGerms && - b1.InfectedAt.Equal(b2.InfectedAt) -} -*/ - -type GermBatch struct { - DirtyGerms, CleanGerms map[int32][]*pb.Germ - GermMap map[int32]*pb.Germ - DishMap map[int32]*Dish - HasPreviousResult bool - DirtyID, CleanID int32 - GermStrain int32 - TotalDirtyGerms int - InfectedAt time.Time -} - -type Dish struct { - pb *pb.Dish - err error -} - -func CreateDish(m *pb.Dish, err error) *Dish { - return &Dish{pb: m, err: err} -} - -func (d *Dish) Proto() (*pb.Dish, error) { - if d.err != nil { - return nil, d.err - } - return d.pb, nil -} diff --git a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project3.go b/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project3.go deleted file mode 100644 index 957d093c7..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project3.go +++ /dev/null @@ -1,82 +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.md file. - -package teststructs - -import ( - "sync" - - pb "github.com/google/go-cmp/cmp/internal/testprotos" -) - -// This is an sanitized example of equality from a real use-case. -// The original equality function was as follows: -/* -func equalDirt(x, y *Dirt) bool { - if !reflect.DeepEqual(x.table, y.table) || - !reflect.DeepEqual(x.ts, y.ts) || - x.Discord != y.Discord || - !pb.Equal(&x.Proto, &y.Proto) || - len(x.wizard) != len(y.wizard) || - len(x.sadistic) != len(y.sadistic) || - x.lastTime != y.lastTime { - return false - } - for k, vx := range x.wizard { - vy, ok := y.wizard[k] - if !ok || !pb.Equal(vx, vy) { - return false - } - } - for k, vx := range x.sadistic { - vy, ok := y.sadistic[k] - if !ok || !pb.Equal(vx, vy) { - return false - } - } - return true -} -*/ - -type FakeMutex struct { - sync.Locker - x struct{} -} - -type Dirt struct { - table Table // Always concrete type of MockTable - ts Timestamp - Discord DiscordState - Proto pb.Dirt - wizard map[string]*pb.Wizard - sadistic map[string]*pb.Sadistic - lastTime int64 - mu FakeMutex -} - -type DiscordState int - -type Timestamp int64 - -func (d *Dirt) SetTable(t Table) { d.table = t } -func (d *Dirt) SetTimestamp(t Timestamp) { d.ts = t } -func (d *Dirt) SetWizard(m map[string]*pb.Wizard) { d.wizard = m } -func (d *Dirt) SetSadistic(m map[string]*pb.Sadistic) { d.sadistic = m } -func (d *Dirt) SetLastTime(t int64) { d.lastTime = t } - -type Table interface { - Operation1() error - Operation2() error - Operation3() error -} - -type MockTable struct { - state []string -} - -func CreateMockTable(s []string) *MockTable { return &MockTable{s} } -func (mt *MockTable) Operation1() error { return nil } -func (mt *MockTable) Operation2() error { return nil } -func (mt *MockTable) Operation3() error { return nil } -func (mt *MockTable) State() []string { return mt.state } diff --git a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project4.go b/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project4.go deleted file mode 100644 index 49920f237..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/project4.go +++ /dev/null @@ -1,142 +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.md file. - -package teststructs - -import ( - "time" - - pb "github.com/google/go-cmp/cmp/internal/testprotos" -) - -// This is an sanitized example of equality from a real use-case. -// The original equality function was as follows: -/* -func equalCartel(x, y Cartel) bool { - if !(equalHeadquarter(x.Headquarter, y.Headquarter) && - x.Source() == y.Source() && - x.CreationDate().Equal(y.CreationDate()) && - x.Boss() == y.Boss() && - x.LastCrimeDate().Equal(y.LastCrimeDate())) { - return false - } - if len(x.Poisons()) != len(y.Poisons()) { - return false - } - for i := range x.Poisons() { - if !equalPoison(*x.Poisons()[i], *y.Poisons()[i]) { - return false - } - } - return true -} -func equalHeadquarter(x, y Headquarter) bool { - xr, yr := x.Restrictions(), y.Restrictions() - return x.ID() == y.ID() && - x.Location() == y.Location() && - reflect.DeepEqual(x.SubDivisions(), y.SubDivisions()) && - x.IncorporatedDate().Equal(y.IncorporatedDate()) && - pb.Equal(x.MetaData(), y.MetaData()) && - bytes.Equal(x.PrivateMessage(), y.PrivateMessage()) && - bytes.Equal(x.PublicMessage(), y.PublicMessage()) && - x.HorseBack() == y.HorseBack() && - x.Rattle() == y.Rattle() && - x.Convulsion() == y.Convulsion() && - x.Expansion() == y.Expansion() && - x.Status() == y.Status() && - pb.Equal(&xr, &yr) && - x.CreationTime().Equal(y.CreationTime()) -} -func equalPoison(x, y Poison) bool { - return x.PoisonType() == y.PoisonType() && - x.Expiration().Equal(y.Expiration()) && - x.Manufacturer() == y.Manufacturer() && - x.Potency() == y.Potency() -} -*/ - -type Cartel struct { - Headquarter - source string - creationDate time.Time - boss string - lastCrimeDate time.Time - poisons []*Poison -} - -func (p Cartel) Source() string { return p.source } -func (p Cartel) CreationDate() time.Time { return p.creationDate } -func (p Cartel) Boss() string { return p.boss } -func (p Cartel) LastCrimeDate() time.Time { return p.lastCrimeDate } -func (p Cartel) Poisons() []*Poison { return p.poisons } - -func (p *Cartel) SetSource(x string) { p.source = x } -func (p *Cartel) SetCreationDate(x time.Time) { p.creationDate = x } -func (p *Cartel) SetBoss(x string) { p.boss = x } -func (p *Cartel) SetLastCrimeDate(x time.Time) { p.lastCrimeDate = x } -func (p *Cartel) SetPoisons(x []*Poison) { p.poisons = x } - -type Headquarter struct { - id uint64 - location string - subDivisions []string - incorporatedDate time.Time - metaData *pb.MetaData - privateMessage []byte - publicMessage []byte - horseBack string - rattle string - convulsion bool - expansion uint64 - status pb.HoneyStatus - restrictions pb.Restrictions - creationTime time.Time -} - -func (hq Headquarter) ID() uint64 { return hq.id } -func (hq Headquarter) Location() string { return hq.location } -func (hq Headquarter) SubDivisions() []string { return hq.subDivisions } -func (hq Headquarter) IncorporatedDate() time.Time { return hq.incorporatedDate } -func (hq Headquarter) MetaData() *pb.MetaData { return hq.metaData } -func (hq Headquarter) PrivateMessage() []byte { return hq.privateMessage } -func (hq Headquarter) PublicMessage() []byte { return hq.publicMessage } -func (hq Headquarter) HorseBack() string { return hq.horseBack } -func (hq Headquarter) Rattle() string { return hq.rattle } -func (hq Headquarter) Convulsion() bool { return hq.convulsion } -func (hq Headquarter) Expansion() uint64 { return hq.expansion } -func (hq Headquarter) Status() pb.HoneyStatus { return hq.status } -func (hq Headquarter) Restrictions() pb.Restrictions { return hq.restrictions } -func (hq Headquarter) CreationTime() time.Time { return hq.creationTime } - -func (hq *Headquarter) SetID(x uint64) { hq.id = x } -func (hq *Headquarter) SetLocation(x string) { hq.location = x } -func (hq *Headquarter) SetSubDivisions(x []string) { hq.subDivisions = x } -func (hq *Headquarter) SetIncorporatedDate(x time.Time) { hq.incorporatedDate = x } -func (hq *Headquarter) SetMetaData(x *pb.MetaData) { hq.metaData = x } -func (hq *Headquarter) SetPrivateMessage(x []byte) { hq.privateMessage = x } -func (hq *Headquarter) SetPublicMessage(x []byte) { hq.publicMessage = x } -func (hq *Headquarter) SetHorseBack(x string) { hq.horseBack = x } -func (hq *Headquarter) SetRattle(x string) { hq.rattle = x } -func (hq *Headquarter) SetConvulsion(x bool) { hq.convulsion = x } -func (hq *Headquarter) SetExpansion(x uint64) { hq.expansion = x } -func (hq *Headquarter) SetStatus(x pb.HoneyStatus) { hq.status = x } -func (hq *Headquarter) SetRestrictions(x pb.Restrictions) { hq.restrictions = x } -func (hq *Headquarter) SetCreationTime(x time.Time) { hq.creationTime = x } - -type Poison struct { - poisonType pb.PoisonType - expiration time.Time - manufacturer string - potency int -} - -func (p Poison) PoisonType() pb.PoisonType { return p.poisonType } -func (p Poison) Expiration() time.Time { return p.expiration } -func (p Poison) Manufacturer() string { return p.manufacturer } -func (p Poison) Potency() int { return p.potency } - -func (p *Poison) SetPoisonType(x pb.PoisonType) { p.poisonType = x } -func (p *Poison) SetExpiration(x time.Time) { p.expiration = x } -func (p *Poison) SetManufacturer(x string) { p.manufacturer = x } -func (p *Poison) SetPotency(x int) { p.potency = x } diff --git a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/structs.go b/vendor/github.com/google/go-cmp/cmp/internal/teststructs/structs.go deleted file mode 100644 index 6b4d2a725..000000000 --- a/vendor/github.com/google/go-cmp/cmp/internal/teststructs/structs.go +++ /dev/null @@ -1,197 +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.md file. - -package teststructs - -type InterfaceA interface { - InterfaceA() -} - -type ( - StructA struct{ X string } // Equal method on value receiver - StructB struct{ X string } // Equal method on pointer receiver - StructC struct{ X string } // Equal method (with interface argument) on value receiver - StructD struct{ X string } // Equal method (with interface argument) on pointer receiver - StructE struct{ X string } // Equal method (with interface argument on value receiver) on pointer receiver - StructF struct{ X string } // Equal method (with interface argument on pointer receiver) on value receiver - - // These embed the above types as a value. - StructA1 struct { - StructA - X string - } - StructB1 struct { - StructB - X string - } - StructC1 struct { - StructC - X string - } - StructD1 struct { - StructD - X string - } - StructE1 struct { - StructE - X string - } - StructF1 struct { - StructF - X string - } - - // These embed the above types as a pointer. - StructA2 struct { - *StructA - X string - } - StructB2 struct { - *StructB - X string - } - StructC2 struct { - *StructC - X string - } - StructD2 struct { - *StructD - X string - } - StructE2 struct { - *StructE - X string - } - StructF2 struct { - *StructF - X string - } - - StructNo struct{ X string } // Equal method (with interface argument) on non-satisfying receiver - - AssignA func() int - AssignB struct{ A int } - AssignC chan bool - AssignD <-chan bool -) - -func (x StructA) Equal(y StructA) bool { return true } -func (x *StructB) Equal(y *StructB) bool { return true } -func (x StructC) Equal(y InterfaceA) bool { return true } -func (x StructC) InterfaceA() {} -func (x *StructD) Equal(y InterfaceA) bool { return true } -func (x *StructD) InterfaceA() {} -func (x *StructE) Equal(y InterfaceA) bool { return true } -func (x StructE) InterfaceA() {} -func (x StructF) Equal(y InterfaceA) bool { return true } -func (x *StructF) InterfaceA() {} -func (x StructNo) Equal(y InterfaceA) bool { return true } - -func (x AssignA) Equal(y func() int) bool { return true } -func (x AssignB) Equal(y struct{ A int }) bool { return true } -func (x AssignC) Equal(y chan bool) bool { return true } -func (x AssignD) Equal(y <-chan bool) bool { return true } - -var _ = func( - a StructA, b StructB, c StructC, d StructD, e StructE, f StructF, - ap *StructA, bp *StructB, cp *StructC, dp *StructD, ep *StructE, fp *StructF, - a1 StructA1, b1 StructB1, c1 StructC1, d1 StructD1, e1 StructE1, f1 StructF1, - a2 StructA2, b2 StructB2, c2 StructC2, d2 StructD2, e2 StructE2, f2 StructF1, -) { - a.Equal(a) - b.Equal(&b) - c.Equal(c) - d.Equal(&d) - e.Equal(e) - f.Equal(&f) - - ap.Equal(*ap) - bp.Equal(bp) - cp.Equal(*cp) - dp.Equal(dp) - ep.Equal(*ep) - fp.Equal(fp) - - a1.Equal(a1.StructA) - b1.Equal(&b1.StructB) - c1.Equal(c1) - d1.Equal(&d1) - e1.Equal(e1) - f1.Equal(&f1) - - a2.Equal(*a2.StructA) - b2.Equal(b2.StructB) - c2.Equal(c2) - d2.Equal(&d2) - e2.Equal(e2) - f2.Equal(&f2) -} - -type ( - privateStruct struct{ Public, private int } - PublicStruct struct{ Public, private int } - ParentStructA struct{ privateStruct } - ParentStructB struct{ PublicStruct } - ParentStructC struct { - privateStruct - Public, private int - } - ParentStructD struct { - PublicStruct - Public, private int - } - ParentStructE struct { - privateStruct - PublicStruct - } - ParentStructF struct { - privateStruct - PublicStruct - Public, private int - } - ParentStructG struct { - *privateStruct - } - ParentStructH struct { - *PublicStruct - } - ParentStructI struct { - *privateStruct - *PublicStruct - } - ParentStructJ struct { - *privateStruct - *PublicStruct - Public PublicStruct - private privateStruct - } -) - -func NewParentStructG() *ParentStructG { - return &ParentStructG{new(privateStruct)} -} -func NewParentStructH() *ParentStructH { - return &ParentStructH{new(PublicStruct)} -} -func NewParentStructI() *ParentStructI { - return &ParentStructI{new(privateStruct), new(PublicStruct)} -} -func NewParentStructJ() *ParentStructJ { - return &ParentStructJ{ - privateStruct: new(privateStruct), PublicStruct: new(PublicStruct), - } -} -func (s *privateStruct) SetPrivate(i int) { s.private = i } -func (s *PublicStruct) SetPrivate(i int) { s.private = i } -func (s *ParentStructC) SetPrivate(i int) { s.private = i } -func (s *ParentStructD) SetPrivate(i int) { s.private = i } -func (s *ParentStructF) SetPrivate(i int) { s.private = i } -func (s *ParentStructA) PrivateStruct() *privateStruct { return &s.privateStruct } -func (s *ParentStructC) PrivateStruct() *privateStruct { return &s.privateStruct } -func (s *ParentStructE) PrivateStruct() *privateStruct { return &s.privateStruct } -func (s *ParentStructF) PrivateStruct() *privateStruct { return &s.privateStruct } -func (s *ParentStructG) PrivateStruct() *privateStruct { return s.privateStruct } -func (s *ParentStructI) PrivateStruct() *privateStruct { return s.privateStruct } -func (s *ParentStructJ) PrivateStruct() *privateStruct { return s.privateStruct } -func (s *ParentStructJ) Private() *privateStruct { return &s.private } diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go b/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go index 938f646f0..24fbae6e3 100644 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go +++ b/vendor/github.com/google/go-cmp/cmp/internal/value/sort.go @@ -19,7 +19,7 @@ func SortKeys(vs []reflect.Value) []reflect.Value { } // Sort the map keys. - sort.Slice(vs, func(i, j int) bool { return isLess(vs[i], vs[j]) }) + sort.SliceStable(vs, func(i, j int) bool { return isLess(vs[i], vs[j]) }) // Deduplicate keys (fails for NaNs). vs2 := vs[:1] @@ -42,6 +42,8 @@ func isLess(x, y reflect.Value) bool { case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return x.Uint() < y.Uint() case reflect.Float32, reflect.Float64: + // NOTE: This does not sort -0 as less than +0 + // since Go maps treat -0 and +0 as equal keys. fx, fy := x.Float(), y.Float() return fx < fy || math.IsNaN(fx) && !math.IsNaN(fy) case reflect.Complex64, reflect.Complex128: diff --git a/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go b/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go index d13a12ccf..06a8ffd03 100644 --- a/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go +++ b/vendor/github.com/google/go-cmp/cmp/internal/value/zero.go @@ -4,7 +4,10 @@ package value -import "reflect" +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. @@ -17,9 +20,9 @@ func IsZero(v reflect.Value) bool { case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return v.Uint() == 0 case reflect.Float32, reflect.Float64: - return v.Float() == 0 + return math.Float64bits(v.Float()) == 0 case reflect.Complex64, reflect.Complex128: - return v.Complex() == 0 + return math.Float64bits(real(v.Complex())) == 0 && math.Float64bits(imag(v.Complex())) == 0 case reflect.String: return v.String() == "" case reflect.UnsafePointer: diff --git a/vendor/github.com/google/go-cmp/cmp/options.go b/vendor/github.com/google/go-cmp/cmp/options.go index 793448160..abbd2a63b 100644 --- a/vendor/github.com/google/go-cmp/cmp/options.go +++ b/vendor/github.com/google/go-cmp/cmp/options.go @@ -225,8 +225,20 @@ func (validator) apply(s *state, vx, vy reflect.Value) { // Unable to Interface implies unexported field without visibility access. if !vx.CanInterface() || !vy.CanInterface() { - const help = "consider using a custom Comparer; if you control the implementation of type, you can also consider AllowUnexported or cmpopts.IgnoreUnexported" - panic(fmt.Sprintf("cannot handle unexported field: %#v\n%s", s.curPath, help)) + const help = "consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported" + var name string + if t := s.curPath.Index(-2).Type(); t.Name() != "" { + // Named type with unexported fields. + name = fmt.Sprintf("%q.%v", t.PkgPath(), t.Name()) // e.g., "path/to/package".MyType + } else { + // Unnamed type with unexported fields. Derive PkgPath from field. + var pkgPath string + for i := 0; i < t.NumField() && pkgPath == ""; i++ { + pkgPath = t.Field(i).PkgPath + } + name = fmt.Sprintf("%q.(%v)", pkgPath, t.String()) // e.g., "path/to/package".(struct { a int }) + } + panic(fmt.Sprintf("cannot handle unexported field at %#v:\n\t%v\n%s", s.curPath, name, help)) } panic("not reachable") @@ -360,9 +372,8 @@ func (cm comparer) String() string { return fmt.Sprintf("Comparer(%s)", function.NameOf(cm.fnc)) } -// AllowUnexported returns an Option that forcibly allows operations on -// unexported fields in certain structs, which are specified by passing in a -// value of each struct type. +// Exporter returns an Option that specifies whether Equal is allowed to +// introspect into the unexported fields of certain struct types. // // Users of this option must understand that comparing on unexported fields // from external packages is not safe since changes in the internal @@ -386,10 +397,24 @@ func (cm comparer) String() string { // // In other cases, the cmpopts.IgnoreUnexported option can be used to ignore // all unexported fields on specified struct types. -func AllowUnexported(types ...interface{}) Option { - if !supportAllowUnexported { - panic("AllowUnexported is not supported on purego builds, Google App Engine Standard, or GopherJS") +func Exporter(f func(reflect.Type) bool) Option { + if !supportExporters { + panic("Exporter is not supported on purego builds") } + return exporter(f) +} + +type exporter func(reflect.Type) bool + +func (exporter) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { + panic("not implemented") +} + +// AllowUnexported returns an Options that allows Equal to forcibly introspect +// unexported fields of the specified struct types. +// +// See Exporter for the proper use of this option. +func AllowUnexported(types ...interface{}) Option { m := make(map[reflect.Type]bool) for _, typ := range types { t := reflect.TypeOf(typ) @@ -398,13 +423,7 @@ func AllowUnexported(types ...interface{}) Option { } m[t] = true } - return visibleStructs(m) -} - -type visibleStructs map[reflect.Type]bool - -func (visibleStructs) filter(_ *state, _ reflect.Type, _, _ reflect.Value) applicableOption { - panic("not implemented") + return exporter(func(t reflect.Type) bool { return m[t] }) } // Result represents the comparison result for a single node and @@ -436,6 +455,11 @@ func (r Result) ByFunc() bool { return r.flags&reportByFunc != 0 } +// ByCycle reports whether a reference cycle was detected. +func (r Result) ByCycle() bool { + return r.flags&reportByCycle != 0 +} + type resultFlags uint const ( @@ -446,6 +470,7 @@ const ( reportByIgnore reportByMethod reportByFunc + reportByCycle ) // Reporter is an Option that can be passed to Equal. When Equal traverses diff --git a/vendor/github.com/google/go-cmp/cmp/path.go b/vendor/github.com/google/go-cmp/cmp/path.go index 96fffd291..509d6b852 100644 --- a/vendor/github.com/google/go-cmp/cmp/path.go +++ b/vendor/github.com/google/go-cmp/cmp/path.go @@ -10,6 +10,8 @@ import ( "strings" "unicode" "unicode/utf8" + + "github.com/google/go-cmp/cmp/internal/value" ) // Path is a list of PathSteps describing the sequence of operations to get @@ -41,7 +43,7 @@ type PathStep interface { // In some cases, one or both may be invalid or have restrictions: // • For StructField, both are not interface-able if the current field // is unexported and the struct type is not explicitly permitted by - // AllowUnexported to traverse unexported fields. + // an Exporter to traverse unexported fields. // • For SliceIndex, one may be invalid if an element is missing from // either the x or y slice. // • For MapIndex, one may be invalid if an entry is missing from @@ -207,6 +209,7 @@ type SliceIndex struct{ *sliceIndex } type sliceIndex struct { pathStep xkey, ykey int + isSlice bool // False for reflect.Array } func (si SliceIndex) Type() reflect.Type { return si.typ } @@ -301,6 +304,72 @@ func (tf Transform) Func() reflect.Value { return tf.trans.fnc } // The == operator can be used to detect the exact option used. func (tf Transform) Option() Option { return tf.trans } +// pointerPath represents a dual-stack of pointers encountered when +// recursively traversing the x and y values. This data structure supports +// detection of cycles and determining whether the cycles are equal. +// In Go, cycles can occur via pointers, slices, and maps. +// +// The pointerPath uses a map to represent a stack; where descension into a +// pointer pushes the address onto the stack, and ascension from a pointer +// pops the address from the stack. Thus, when traversing into a pointer from +// reflect.Ptr, reflect.Slice element, or reflect.Map, we can detect cycles +// by checking whether the pointer has already been visited. The cycle detection +// uses a seperate stack for the x and y values. +// +// If a cycle is detected we need to determine whether the two pointers +// should be considered equal. The definition of equality chosen by Equal +// requires two graphs to have the same structure. To determine this, both the +// x and y values must have a cycle where the previous pointers were also +// encountered together as a pair. +// +// Semantically, this is equivalent to augmenting Indirect, SliceIndex, and +// MapIndex with pointer information for the x and y values. +// Suppose px and py are two pointers to compare, we then search the +// Path for whether px was ever encountered in the Path history of x, and +// similarly so with py. If either side has a cycle, the comparison is only +// equal if both px and py have a cycle resulting from the same PathStep. +// +// Using a map as a stack is more performant as we can perform cycle detection +// in O(1) instead of O(N) where N is len(Path). +type pointerPath struct { + // mx is keyed by x pointers, where the value is the associated y pointer. + mx map[value.Pointer]value.Pointer + // my is keyed by y pointers, where the value is the associated x pointer. + my map[value.Pointer]value.Pointer +} + +func (p *pointerPath) Init() { + p.mx = make(map[value.Pointer]value.Pointer) + p.my = make(map[value.Pointer]value.Pointer) +} + +// Push indicates intent to descend into pointers vx and vy where +// visited reports whether either has been seen before. If visited before, +// equal reports whether both pointers were encountered together. +// Pop must be called if and only if the pointers were never visited. +// +// The pointers vx and vy must be a reflect.Ptr, reflect.Slice, or reflect.Map +// and be non-nil. +func (p pointerPath) Push(vx, vy reflect.Value) (equal, visited bool) { + px := value.PointerOf(vx) + py := value.PointerOf(vy) + _, ok1 := p.mx[px] + _, ok2 := p.my[py] + if ok1 || ok2 { + equal = p.mx[px] == py && p.my[py] == px // Pointers paired together + return equal, true + } + p.mx[px] = py + p.my[py] = px + return false, false +} + +// Pop ascends from pointers vx and vy. +func (p pointerPath) Pop(vx, vy reflect.Value) { + delete(p.mx, value.PointerOf(vx)) + delete(p.my, value.PointerOf(vy)) +} + // isExported reports whether the identifier is exported. func isExported(id string) bool { r, _ := utf8.DecodeRuneInString(id) diff --git a/vendor/github.com/google/go-cmp/cmp/report_compare.go b/vendor/github.com/google/go-cmp/cmp/report_compare.go index 05efb992c..17a05eede 100644 --- a/vendor/github.com/google/go-cmp/cmp/report_compare.go +++ b/vendor/github.com/google/go-cmp/cmp/report_compare.go @@ -168,7 +168,7 @@ func (opts formatOptions) formatDiffList(recs []reportRecord, k reflect.Kind) te var isZero bool switch opts.DiffMode { case diffIdentical: - isZero = value.IsZero(r.Value.ValueX) || value.IsZero(r.Value.ValueX) + isZero = value.IsZero(r.Value.ValueX) || value.IsZero(r.Value.ValueY) case diffRemoved: isZero = value.IsZero(r.Value.ValueX) case diffInserted: diff --git a/vendor/github.com/google/go-cmp/cmp/report_reflect.go b/vendor/github.com/google/go-cmp/cmp/report_reflect.go index 5521c604c..2761b6289 100644 --- a/vendor/github.com/google/go-cmp/cmp/report_reflect.go +++ b/vendor/github.com/google/go-cmp/cmp/report_reflect.go @@ -208,7 +208,6 @@ func (opts formatOptions) FormatValue(v reflect.Value, m visitedPointers) (out t func formatMapKey(v reflect.Value) string { var opts formatOptions opts.TypeMode = elideType - opts.AvoidStringer = true opts.ShallowPointers = true s := opts.FormatValue(v, visitedPointers{}).String() return strings.TrimSpace(s) diff --git a/vendor/github.com/google/go-cmp/cmp/report_slices.go b/vendor/github.com/google/go-cmp/cmp/report_slices.go index 8cb3265e7..eafcf2e4c 100644 --- a/vendor/github.com/google/go-cmp/cmp/report_slices.go +++ b/vendor/github.com/google/go-cmp/cmp/report_slices.go @@ -90,7 +90,7 @@ func (opts formatOptions) FormatDiffSlice(v *valueNode) textNode { } if r == '\n' { if maxLineLen < i-lastLineIdx { - lastLineIdx = i - lastLineIdx + maxLineLen = i - lastLineIdx } lastLineIdx = i + 1 numLines++ @@ -322,7 +322,7 @@ func coalesceInterveningIdentical(groups []diffStats, windowSize int) []diffStat hadX, hadY := prev.NumRemoved > 0, prev.NumInserted > 0 hasX, hasY := next.NumRemoved > 0, next.NumInserted > 0 if ((hadX || hasX) && (hadY || hasY)) && curr.NumIdentical <= windowSize { - *prev = (*prev).Append(*curr).Append(*next) + *prev = prev.Append(*curr).Append(*next) groups = groups[:len(groups)-1] // Truncate off equal group continue } diff --git a/vendor/github.com/google/go-cmp/cmp/report_text.go b/vendor/github.com/google/go-cmp/cmp/report_text.go index 80605d0e4..8b8fcab7b 100644 --- a/vendor/github.com/google/go-cmp/cmp/report_text.go +++ b/vendor/github.com/google/go-cmp/cmp/report_text.go @@ -19,6 +19,11 @@ var randBool = rand.New(rand.NewSource(time.Now().Unix())).Intn(2) == 0 type indentMode int func (n indentMode) appendIndent(b []byte, d diffMode) []byte { + // The output of Diff is documented as being unstable to provide future + // flexibility in changing the output for more humanly readable reports. + // This logic intentionally introduces instability to the exact output + // so that users can detect accidental reliance on stability early on, + // rather than much later when an actual change to the format occurs. if flags.Deterministic || randBool { // Use regular spaces (U+0020). switch d { @@ -360,7 +365,7 @@ func (s diffStats) String() string { // Pluralize the name (adjusting for some obscure English grammar rules). name := s.Name if sum > 1 { - name = name + "s" + name += "s" if strings.HasSuffix(name, "ys") { name = name[:len(name)-2] + "ies" // e.g., "entrys" => "entries" } diff --git a/vendor/github.com/googleapis/gax-go/.gitignore b/vendor/github.com/googleapis/gax-go/.gitignore deleted file mode 100644 index 289bf1eb7..000000000 --- a/vendor/github.com/googleapis/gax-go/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.cover diff --git a/vendor/github.com/googleapis/gax-go/CODE_OF_CONDUCT.md b/vendor/github.com/googleapis/gax-go/CODE_OF_CONDUCT.md deleted file mode 100644 index 46b2a08ea..000000000 --- a/vendor/github.com/googleapis/gax-go/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,43 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. - -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) diff --git a/vendor/github.com/googleapis/gax-go/CONTRIBUTING.md b/vendor/github.com/googleapis/gax-go/CONTRIBUTING.md deleted file mode 100644 index b0404fb64..000000000 --- a/vendor/github.com/googleapis/gax-go/CONTRIBUTING.md +++ /dev/null @@ -1,32 +0,0 @@ -Want to contribute? Great! First, read this page (including the small print at the end). - -### Before you contribute -Before we can use your code, you must sign the -[Google Individual Contributor License Agreement] -(https://cla.developers.google.com/about/google-individual) -(CLA), which you can do online. The CLA is necessary mainly because you own the -copyright to your changes, even after your contribution becomes part of our -codebase, so we need your permission to use and distribute your code. We also -need to be sure of various other things—for instance that you'll tell us if you -know that your code infringes on other people's patents. You don't have to sign -the CLA until after you've submitted your code for review and a member has -approved it, but you must do it before we can put your code into our codebase. -Before you start working on a larger contribution, you should get in touch with -us first through the issue tracker with your idea so that we can help out and -possibly guide you. Coordinating up front makes it much easier to avoid -frustration later on. - -### Code reviews -All submissions, including submissions by project members, require review. We -use Github pull requests for this purpose. - -### Breaking code changes -When a breaking change is added, CI/CD will fail. If the change is expected, -add a BREAKING_CHANGE_ACCEPTABLE=<reason> line to the CL description. This will -cause CI/CD to skip checking breaking changes. - -### The small print -Contributions made by corporations are covered by a different agreement than -the one above, the -[Software Grant and Corporate Contributor License Agreement] -(https://cla.developers.google.com/about/google-corporate). diff --git a/vendor/github.com/googleapis/gax-go/README.md b/vendor/github.com/googleapis/gax-go/README.md deleted file mode 100644 index aae170fb6..000000000 --- a/vendor/github.com/googleapis/gax-go/README.md +++ /dev/null @@ -1,27 +0,0 @@ -Google API Extensions for Go -============================ - -[](https://godoc.org/github.com/googleapis/gax-go) - -Google API Extensions for Go (gax-go) is a set of modules which aids the -development of APIs for clients and servers based on `gRPC` and Google API -conventions. - -To install the API extensions, use: - -``` -go get -u github.com/googleapis/gax-go/v2 -``` - -**Note:** Application code will rarely need to use this library directly, -but the code generated automatically from API definition files can use it -to simplify code generation and to provide more convenient and idiomatic API surface. - -Go Versions -=========== -This library requires Go 1.6 or above. - -License -======= -BSD - please see [LICENSE](https://github.com/googleapis/gax-go/blob/master/LICENSE) -for more information. diff --git a/vendor/github.com/googleapis/gax-go/RELEASING.md b/vendor/github.com/googleapis/gax-go/RELEASING.md deleted file mode 100644 index 0557654b2..000000000 --- a/vendor/github.com/googleapis/gax-go/RELEASING.md +++ /dev/null @@ -1,30 +0,0 @@ -# How to release v1 - -1. Determine the current release version with `git tag -l`. It should look - something like `vX.Y.Z`. We'll call the current version `$CV` and the new - version `$NV`. -1. On master, run `git log $CV..` to list all the changes since the last - release. - a. NOTE: Some commits may pertain to only v1 or v2. Manually introspect - each commit to figure which occurred in v1. -1. Edit `CHANGES.md` to include a summary of the changes. -1. Mail the CL containing the `CHANGES.md` changes. When the CL is approved, - submit it. -1. Without submitting any other CLs: - a. Switch to master. - b. `git pull` - c. Tag the repo with the next version: `git tag $NV`. It should be of the - form `v1.Y.Z`. - d. Push the tag: `git push origin $NV`. -1. Update [the releases page](https://github.com/googleapis/google-cloud-go/releases) - with the new release, copying the contents of the CHANGES.md. - -# How to release v2 - -Same process as v1, once again noting that the commit list may include v1 -commits (which should be pruned out). Note also whilst v1 tags are `v1.Y.Z`, v2 -tags are `v2.Y.Z`. - -# On releasing multiple major versions - -Please see https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher. diff --git a/vendor/github.com/googleapis/gax-go/call_option.go b/vendor/github.com/googleapis/gax-go/call_option.go deleted file mode 100644 index 5bd48972b..000000000 --- a/vendor/github.com/googleapis/gax-go/call_option.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016, Google Inc. -// 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. - -package gax - -import ( - v2 "github.com/googleapis/gax-go/v2" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" -) - -// CallOption is an option used by Invoke to control behaviors of RPC calls. -// CallOption works by modifying relevant fields of CallSettings. -type CallOption = v2.CallOption - -// Retryer is used by Invoke to determine retry behavior. -type Retryer = v2.Retryer - -// WithRetry sets CallSettings.Retry to fn. -func WithRetry(fn func() Retryer) CallOption { - return v2.WithRetry(fn) -} - -// OnCodes returns a Retryer that retries if and only if -// the previous attempt returns a GRPC error whose error code is stored in cc. -// Pause times between retries are specified by bo. -// -// bo is only used for its parameters; each Retryer has its own copy. -func OnCodes(cc []codes.Code, bo Backoff) Retryer { - return v2.OnCodes(cc, bo) -} - -// Backoff implements exponential backoff. -// The wait time between retries is a random value between 0 and the "retry envelope". -// The envelope starts at Initial and increases by the factor of Multiplier every retry, -// but is capped at Max. -type Backoff = v2.Backoff - -// WithGRPCOptions allows passing gRPC call options during client creation. -func WithGRPCOptions(opt ...grpc.CallOption) CallOption { - return v2.WithGRPCOptions(opt...) -} - -// CallSettings allow fine-grained control over how calls are made. -type CallSettings = v2.CallSettings diff --git a/vendor/github.com/googleapis/gax-go/gax.go b/vendor/github.com/googleapis/gax-go/gax.go deleted file mode 100644 index 006739804..000000000 --- a/vendor/github.com/googleapis/gax-go/gax.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016, Google Inc. -// 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. - -// Package gax contains a set of modules which aid the development of APIs -// for clients and servers based on gRPC and Google API conventions. -// -// Application code will rarely need to use this library directly. -// However, code generated automatically from API definition files can use it -// to simplify code generation and to provide more convenient and idiomatic API surfaces. -package gax - -// Version specifies the gax version. -const Version = "1.0.1" diff --git a/vendor/github.com/googleapis/gax-go/go.mod b/vendor/github.com/googleapis/gax-go/go.mod deleted file mode 100644 index 8b088e52b..000000000 --- a/vendor/github.com/googleapis/gax-go/go.mod +++ /dev/null @@ -1,13 +0,0 @@ -module github.com/googleapis/gax-go - -go 1.11 - -require ( - github.com/golang/protobuf v1.3.1 - github.com/googleapis/gax-go/v2 v2.0.5 - golang.org/x/exp v0.0.0-20190221220918-438050ddec5e - golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 - golang.org/x/tools v0.0.0-20190114222345-bf090417da8b - google.golang.org/grpc v1.19.0 - honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 -) diff --git a/vendor/github.com/googleapis/gax-go/go.sum b/vendor/github.com/googleapis/gax-go/go.sum deleted file mode 100644 index 8fd8a46c1..000000000 --- a/vendor/github.com/googleapis/gax-go/go.sum +++ /dev/null @@ -1,35 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -golang.org/x/exp v0.0.0-20190221220918-438050ddec5e h1:dVreTP5bOOWt5GFwwvgTE2iU0TkIqi2x3r0b8qGlp6k= -golang.org/x/exp v0.0.0-20190221220918-438050ddec5e/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b h1:qMK98NmNCRVDIYFycQ5yVRkvgDUFfdP8Ip4KqmDEB7g= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/github.com/googleapis/gax-go/header.go b/vendor/github.com/googleapis/gax-go/header.go deleted file mode 100644 index e1a0af1ba..000000000 --- a/vendor/github.com/googleapis/gax-go/header.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018, Google Inc. -// 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. - -package gax - -import v2 "github.com/googleapis/gax-go/v2" - -// XGoogHeader is for use by the Google Cloud Libraries only. -// -// XGoogHeader formats key-value pairs. -// The resulting string is suitable for x-goog-api-client header. -func XGoogHeader(keyval ...string) string { - return v2.XGoogHeader(keyval...) -} diff --git a/vendor/github.com/googleapis/gax-go/invoke.go b/vendor/github.com/googleapis/gax-go/invoke.go deleted file mode 100644 index 6422d3f73..000000000 --- a/vendor/github.com/googleapis/gax-go/invoke.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2016, Google Inc. -// 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. - -package gax - -import ( - "context" - "time" - - v2 "github.com/googleapis/gax-go/v2" -) - -// APICall is a user defined call stub. -type APICall = v2.APICall - -// Invoke calls the given APICall, -// performing retries as specified by opts, if any. -func Invoke(ctx context.Context, call APICall, opts ...CallOption) error { - return v2.Invoke(ctx, call, opts...) -} - -// Sleep is similar to time.Sleep, but it can be interrupted by ctx.Done() closing. -// If interrupted, Sleep returns ctx.Err(). -func Sleep(ctx context.Context, d time.Duration) error { - return v2.Sleep(ctx, d) -} diff --git a/vendor/github.com/googleapis/gax-go/tools.go b/vendor/github.com/googleapis/gax-go/tools.go deleted file mode 100644 index ffb3ad482..000000000 --- a/vendor/github.com/googleapis/gax-go/tools.go +++ /dev/null @@ -1,33 +0,0 @@ -// +build tools - -// Copyright 2019 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This package exists to cause `go mod` and `go get` to believe these tools -// are dependencies, even though they are not runtime dependencies of any -// package (these are tools used by our CI builds). This means they will appear -// in our `go.mod` file, but will not be a part of the build. Also, since the -// build target is something non-existent, these should not be included in any -// binaries. - -package gax - -import ( - _ "github.com/golang/protobuf/proto" - _ "github.com/golang/protobuf/protoc-gen-go" - _ "golang.org/x/exp/cmd/apidiff" - _ "golang.org/x/lint/golint" - _ "golang.org/x/tools/cmd/goimports" - _ "honnef.co/go/tools/cmd/staticcheck" -) diff --git a/vendor/github.com/googleapis/gax-go/LICENSE b/vendor/github.com/googleapis/gax-go/v2/LICENSE index 6d16b6578..6d16b6578 100644 --- a/vendor/github.com/googleapis/gax-go/LICENSE +++ b/vendor/github.com/googleapis/gax-go/v2/LICENSE diff --git a/vendor/github.com/googleapis/gax-go/v2/call_option.go b/vendor/github.com/googleapis/gax-go/v2/call_option.go index 8b7753969..b1d53dd19 100644 --- a/vendor/github.com/googleapis/gax-go/v2/call_option.go +++ b/vendor/github.com/googleapis/gax-go/v2/call_option.go @@ -94,25 +94,22 @@ func (r *boRetryer) Retry(err error) (time.Duration, bool) { return 0, false } -// Backoff implements exponential backoff. The wait time between retries is a -// random value between 0 and the "retry period" - the time between retries. The -// retry period starts at Initial and increases by the factor of Multiplier -// every retry, but is capped at Max. -// -// Note: MaxNumRetries / RPCDeadline is specifically not provided. These should -// be built on top of Backoff. +// Backoff implements exponential backoff. +// The wait time between retries is a random value between 0 and the "retry envelope". +// The envelope starts at Initial and increases by the factor of Multiplier every retry, +// but is capped at Max. type Backoff struct { - // Initial is the initial value of the retry period, defaults to 1 second. + // Initial is the initial value of the retry envelope, defaults to 1 second. Initial time.Duration - // Max is the maximum value of the retry period, defaults to 30 seconds. + // Max is the maximum value of the retry envelope, defaults to 30 seconds. Max time.Duration - // Multiplier is the factor by which the retry period increases. + // Multiplier is the factor by which the retry envelope increases. // It should be greater than 1 and defaults to 2. Multiplier float64 - // cur is the current retry period. + // cur is the current retry envelope cur time.Duration } diff --git a/vendor/github.com/googleapis/gax-go/v2/gax.go b/vendor/github.com/googleapis/gax-go/v2/gax.go index dfc4beb28..3fd1b0b84 100644 --- a/vendor/github.com/googleapis/gax-go/v2/gax.go +++ b/vendor/github.com/googleapis/gax-go/v2/gax.go @@ -36,4 +36,4 @@ package gax // Version specifies the gax-go version being used. -const Version = "2.0.5" +const Version = "2.0.4" diff --git a/vendor/github.com/googleapis/gax-go/v2/go.mod b/vendor/github.com/googleapis/gax-go/v2/go.mod index e83e87b8b..9cdfaf447 100644 --- a/vendor/github.com/googleapis/gax-go/v2/go.mod +++ b/vendor/github.com/googleapis/gax-go/v2/go.mod @@ -1,5 +1,3 @@ module github.com/googleapis/gax-go/v2 -go 1.11 - require google.golang.org/grpc v1.19.0 diff --git a/vendor/github.com/googleapis/gax-go/v2/invoke.go b/vendor/github.com/googleapis/gax-go/v2/invoke.go index 749b9d234..fe31dd004 100644 --- a/vendor/github.com/googleapis/gax-go/v2/invoke.go +++ b/vendor/github.com/googleapis/gax-go/v2/invoke.go @@ -38,8 +38,8 @@ import ( // APICall is a user defined call stub. type APICall func(context.Context, CallSettings) error -// Invoke calls the given APICall, performing retries as specified by opts, if -// any. +// Invoke calls the given APICall, +// performing retries as specified by opts, if any. func Invoke(ctx context.Context, call APICall, opts ...CallOption) error { var settings CallSettings for _, opt := range opts { diff --git a/vendor/github.com/ianlancetaylor/demangle/c++filt.go b/vendor/github.com/ianlancetaylor/demangle/c++filt.go deleted file mode 100644 index 7ba817c9f..000000000 --- a/vendor/github.com/ianlancetaylor/demangle/c++filt.go +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2015 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. - -// +build ignore - -// This is a program that works like the GNU c++filt program. -// It's here for testing purposes and as an example. - -package main - -import ( - "bufio" - "flag" - "fmt" - "io" - "os" - "strings" - "unicode" - - "github.com/ianlancetaylor/demangle" -) - -func flagUsage() { - usage(os.Stderr, 2) -} - -func usage(w io.Writer, status int) { - fmt.Fprintf(w, "Usage: %s [options] [mangled names]\n", os.Args[0]) - flag.CommandLine.SetOutput(w) - flag.PrintDefaults() - fmt.Fprintln(w, `Demangled names are displayed to stdout -If a name cannot be demangled it is just echoed to stdout. -If no names are provided on the command line, stdin is read.`) - os.Exit(status) -} - -var stripUnderscore = flag.Bool("_", false, "Ignore first leading underscore") -var noParams = flag.Bool("p", false, "Do not display function argument types") -var noVerbose = flag.Bool("i", false, "Do not show implementation details (if any)") -var help = flag.Bool("h", false, "Display help information") -var debug = flag.Bool("d", false, "Display debugging information for strings on command line") - -// Unimplemented c++filt flags: -// -n (opposite of -_) -// -t (demangle types) -// -s (set demangling style) -// -V (print version information) - -// Characters considered to be part of a symbol. -const symbolChars = "_$." - -func main() { - flag.Usage = func() { usage(os.Stderr, 1) } - flag.Parse() - - if *help { - usage(os.Stdout, 0) - } - - out := bufio.NewWriter(os.Stdout) - - if flag.NArg() > 0 { - for _, f := range flag.Args() { - if *debug { - a, err := demangle.ToAST(f, options()...) - if err != nil { - fmt.Fprintf(os.Stderr, "%s: %v\n", f, err) - } else { - fmt.Fprintf(out, "%#v\n", a) - } - } else { - doDemangle(out, f) - } - out.WriteByte('\n') - } - if err := out.Flush(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(2) - } - return - } - - scanner := bufio.NewScanner(bufio.NewReader(os.Stdin)) - for scanner.Scan() { - line := scanner.Text() - start := -1 - for i, c := range line { - if unicode.IsLetter(c) || unicode.IsNumber(c) || strings.ContainsRune(symbolChars, c) { - if start < 0 { - start = i - } - } else { - if start >= 0 { - doDemangle(out, line[start:i]) - } - out.WriteRune(c) - start = -1 - } - } - if start >= 0 { - doDemangle(out, line[start:]) - start = -1 - } - out.WriteByte('\n') - if err := out.Flush(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(2) - } - } -} - -// Demangle a string just as the GNU c++filt program does. -func doDemangle(out *bufio.Writer, name string) { - skip := 0 - if name[0] == '.' || name[0] == '$' { - skip++ - } - if *stripUnderscore && name[skip] == '_' { - skip++ - } - result := demangle.Filter(name[skip:], options()...) - if result == name[skip:] { - out.WriteString(name) - } else { - if name[0] == '.' { - out.WriteByte('.') - } - out.WriteString(result) - } -} - -// options returns the demangling options to use based on the command -// line flags. -func options() []demangle.Option { - var options []demangle.Option - if *noParams { - options = append(options, demangle.NoParams) - } - if !*noVerbose { - options = append(options, demangle.Verbose) - } - return options -} |
