From 748150502ed6fbdf5523a5daa5cc161cc9922291 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 21 Apr 2022 21:24:49 -0400 Subject: [PATCH] Remove package variables Kubernetes-commit: 87494389ac7987ed9586190dc9566669b33a9f7c --- third_party/forked/golang/template/exec.go | 13 +++---- third_party/forked/golang/template/funcs.go | 41 +++++++++------------ 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/third_party/forked/golang/template/exec.go b/third_party/forked/golang/template/exec.go index af8319d7..c2276514 100644 --- a/third_party/forked/golang/template/exec.go +++ b/third_party/forked/golang/template/exec.go @@ -8,18 +8,15 @@ import ( "reflect" ) -var Indirect = indirect -var PrintableValue = printableValue - var ( errorType = reflect.TypeOf((*error)(nil)).Elem() fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() ) -// indirect returns the item at the end of indirection, and a bool to indicate if it's nil. +// Indirect returns the item at the end of indirection, and a bool to indicate if it's nil. // We indirect through pointers and empty interfaces (only) because // non-empty interfaces have methods we might need. -func indirect(v reflect.Value) (rv reflect.Value, isNil bool) { +func Indirect(v reflect.Value) (rv reflect.Value, isNil bool) { for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() { if v.IsNil() { return v, true @@ -31,11 +28,11 @@ func indirect(v reflect.Value) (rv reflect.Value, isNil bool) { return v, false } -// printableValue returns the, possibly indirected, interface value inside v that +// PrintableValue returns the, possibly indirected, interface value inside v that // is best for a call to formatted printer. -func printableValue(v reflect.Value) (interface{}, bool) { +func PrintableValue(v reflect.Value) (interface{}, bool) { if v.Kind() == reflect.Ptr { - v, _ = indirect(v) // fmt.Fprint handles nil. + v, _ = Indirect(v) // fmt.Fprint handles nil. } if !v.IsValid() { return "", true diff --git a/third_party/forked/golang/template/funcs.go b/third_party/forked/golang/template/funcs.go index 7930b25a..f0c8e712 100644 --- a/third_party/forked/golang/template/funcs.go +++ b/third_party/forked/golang/template/funcs.go @@ -8,13 +8,6 @@ import ( "reflect" ) -var Equal = eq -var GreaterEqual = ge -var Greater = gt -var LessEqual = le -var Less = lt -var NotEqual = ne - var ( errBadComparisonType = errors.New("invalid type for comparison") errBadComparison = errors.New("incompatible types for comparison") @@ -52,8 +45,8 @@ func basicKind(v reflect.Value) (kind, error) { return invalidKind, errBadComparisonType } -// eq evaluates the comparison a == b || a == c || ... -func eq(arg1 interface{}, arg2 ...interface{}) (bool, error) { +// Equal evaluates the comparison a == b || a == c || ... +func Equal(arg1 interface{}, arg2 ...interface{}) (bool, error) { v1 := reflect.ValueOf(arg1) k1, err := basicKind(v1) if err != nil { @@ -104,15 +97,15 @@ func eq(arg1 interface{}, arg2 ...interface{}) (bool, error) { return false, nil } -// ne evaluates the comparison a != b. -func ne(arg1, arg2 interface{}) (bool, error) { +// NotEqual evaluates the comparison a != b. +func NotEqual(arg1, arg2 interface{}) (bool, error) { // != is the inverse of ==. - equal, err := eq(arg1, arg2) + equal, err := Equal(arg1, arg2) return !equal, err } -// lt evaluates the comparison a < b. -func lt(arg1, arg2 interface{}) (bool, error) { +// Less evaluates the comparison a < b. +func Less(arg1, arg2 interface{}) (bool, error) { v1 := reflect.ValueOf(arg1) k1, err := basicKind(v1) if err != nil { @@ -153,30 +146,30 @@ func lt(arg1, arg2 interface{}) (bool, error) { return truth, nil } -// le evaluates the comparison <= b. -func le(arg1, arg2 interface{}) (bool, error) { +// LessEqual evaluates the comparison <= b. +func LessEqual(arg1, arg2 interface{}) (bool, error) { // <= is < or ==. - lessThan, err := lt(arg1, arg2) + lessThan, err := Less(arg1, arg2) if lessThan || err != nil { return lessThan, err } - return eq(arg1, arg2) + return Equal(arg1, arg2) } -// gt evaluates the comparison a > b. -func gt(arg1, arg2 interface{}) (bool, error) { +// Greater evaluates the comparison a > b. +func Greater(arg1, arg2 interface{}) (bool, error) { // > is the inverse of <=. - lessOrEqual, err := le(arg1, arg2) + lessOrEqual, err := LessEqual(arg1, arg2) if err != nil { return false, err } return !lessOrEqual, nil } -// ge evaluates the comparison a >= b. -func ge(arg1, arg2 interface{}) (bool, error) { +// GreaterEqual evaluates the comparison a >= b. +func GreaterEqual(arg1, arg2 interface{}) (bool, error) { // >= is the inverse of <. - lessThan, err := lt(arg1, arg2) + lessThan, err := Less(arg1, arg2) if err != nil { return false, err }