From 24fb8b9ee745f2ebd8e5a81cfb6adcb42479a24b Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Sun, 19 May 2019 16:30:47 -0400 Subject: [PATCH] Print package prefix for dumped int value types --- dump/dump.go | 20 ++++++++++---------- dump/utils.go | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dump/dump.go b/dump/dump.go index a9249ec..53345aa 100644 --- a/dump/dump.go +++ b/dump/dump.go @@ -212,15 +212,15 @@ func (s *dumpState) printPrimitivePointer(value reflect.Value, pointerName strin printBool(s.w, v.Bool()) case reflect.Int: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int8: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int16: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int32: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int64: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Uint: printUint(s.w, v) @@ -365,15 +365,15 @@ func (s *dumpState) dumpVal(value reflect.Value) { printBool(s.w, v.Bool()) case reflect.Int: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int8: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int16: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int32: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Int64: - printInt(s.w, v) + printInt(s.w, v, s.config.StripPackageNames) case reflect.Uint: printUint(s.w, v) diff --git a/dump/utils.go b/dump/utils.go index f5b1f95..e8bfb64 100644 --- a/dump/utils.go +++ b/dump/utils.go @@ -28,9 +28,9 @@ func printBool(w io.Writer, value bool) { w.Write([]byte(strconv.FormatBool(value))) } -func printInt(w io.Writer, val reflect.Value) { +func printInt(w io.Writer, val reflect.Value, stripPackageName bool) { typeName := fmt.Sprintf("%s", val.Type()) - if strings.HasPrefix(typeName, "ast.") { + if stripPackageName && strings.HasPrefix(typeName, "ast.") { typeName = typeName[4:] } w.Write([]byte(fmt.Sprintf("%s(%s)", typeName, strconv.FormatInt(val.Int(), 10))))