Remove package variables

Kubernetes-commit: 87494389ac7987ed9586190dc9566669b33a9f7c
This commit is contained in:
Jordan Liggitt
2022-04-21 21:24:49 -04:00
committed by Kubernetes Publisher
parent 28c4a4d40f
commit 748150502e
2 changed files with 22 additions and 32 deletions

View File

@@ -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 "<no value>", true