mirror of
https://github.com/google/go-jsonnet.git
synced 2025-09-30 09:51:03 +02:00
Print package prefix for dumped int value types
This commit is contained in:
parent
ad72eb0fbb
commit
24fb8b9ee7
20
dump/dump.go
20
dump/dump.go
@ -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)
|
||||||
|
@ -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))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user