Print package prefix for dumped int value types

This commit is contained in:
Steve Harris 2019-05-19 16:30:47 -04:00 committed by Stanisław Barzowski
parent ad72eb0fbb
commit 24fb8b9ee7
2 changed files with 12 additions and 12 deletions

View File

@ -212,15 +212,15 @@ func (s *dumpState) printPrimitivePointer(value reflect.Value, pointerName strin
printBool(s.w, v.Bool()) printBool(s.w, v.Bool())
case reflect.Int: case reflect.Int:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int8: case reflect.Int8:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int16: case reflect.Int16:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int32: case reflect.Int32:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int64: case reflect.Int64:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Uint: case reflect.Uint:
printUint(s.w, v) printUint(s.w, v)
@ -365,15 +365,15 @@ func (s *dumpState) dumpVal(value reflect.Value) {
printBool(s.w, v.Bool()) printBool(s.w, v.Bool())
case reflect.Int: case reflect.Int:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int8: case reflect.Int8:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int16: case reflect.Int16:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int32: case reflect.Int32:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Int64: case reflect.Int64:
printInt(s.w, v) printInt(s.w, v, s.config.StripPackageNames)
case reflect.Uint: case reflect.Uint:
printUint(s.w, v) printUint(s.w, v)

View File

@ -28,9 +28,9 @@ func printBool(w io.Writer, value bool) {
w.Write([]byte(strconv.FormatBool(value))) 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()) typeName := fmt.Sprintf("%s", val.Type())
if strings.HasPrefix(typeName, "ast.") { if stripPackageName && strings.HasPrefix(typeName, "ast.") {
typeName = typeName[4:] typeName = typeName[4:]
} }
w.Write([]byte(fmt.Sprintf("%s(%s)", typeName, strconv.FormatInt(val.Int(), 10)))) w.Write([]byte(fmt.Sprintf("%s(%s)", typeName, strconv.FormatInt(val.Int(), 10))))