|
@@ -6,6 +6,7 @@ import (
|
|
"io"
|
|
"io"
|
|
"reflect"
|
|
"reflect"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "time"
|
|
)
|
|
)
|
|
|
|
|
|
const (
|
|
const (
|
|
@@ -52,24 +53,28 @@ func fdump(w io.Writer, rx int, rd int, tab string, value reflect.Value) {
|
|
} else if kindIn(value.Kind(), reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64) {
|
|
} else if kindIn(value.Kind(), reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64) {
|
|
fmt.Fprintf(w, "%+v /* Type:%s */", value, value.Type().String())
|
|
fmt.Fprintf(w, "%+v /* Type:%s */", value, value.Type().String())
|
|
} else if value.Kind() == reflect.Struct {
|
|
} else if value.Kind() == reflect.Struct {
|
|
- ntab := tab + tabSpace
|
|
|
|
- fmt.Fprintf(w, "{")
|
|
|
|
- il := value.NumField()
|
|
|
|
- for i, j := 0, 0; i < il && i < MaxFieldLen; i++ {
|
|
|
|
- tf := value.Type().Field(i)
|
|
|
|
- tag := strings.Split(value.Type().Field(i).Tag.Get("dump"), ",")
|
|
|
|
- if !InStringSlice("ignore", tag...) {
|
|
|
|
- if j > 0 {
|
|
|
|
- fmt.Fprintf(w, ",\n%s\"%s\": ", ntab, tf.Name)
|
|
|
|
- } else {
|
|
|
|
- fmt.Fprintf(w, "\n%s\"%s\": ", ntab, tf.Name)
|
|
|
|
|
|
+ if t, ok := value.Interface().(time.Time); ok {
|
|
|
|
+ fmt.Fprintf(w, "%s /* Type:%s */", t, value.Type())
|
|
|
|
+ } else {
|
|
|
|
+ ntab := tab + tabSpace
|
|
|
|
+ fmt.Fprintf(w, "{ /* Type:%s */", value.Type().String())
|
|
|
|
+ il := value.NumField()
|
|
|
|
+ for i, j := 0, 0; i < il && i < MaxFieldLen; i++ {
|
|
|
|
+ tf := value.Type().Field(i)
|
|
|
|
+ tag := strings.Split(value.Type().Field(i).Tag.Get("dump"), ",")
|
|
|
|
+ if !InStringSlice("ignore", tag...) {
|
|
|
|
+ if j > 0 {
|
|
|
|
+ fmt.Fprintf(w, ",\n%s\"%s\": ", ntab, tf.Name)
|
|
|
|
+ } else {
|
|
|
|
+ fmt.Fprintf(w, "\n%s\"%s\": ", ntab, tf.Name)
|
|
|
|
+ }
|
|
|
|
+ vf := value.Field(i)
|
|
|
|
+ fdump(w, rx, rd+1, ntab, vf)
|
|
|
|
+ j++
|
|
}
|
|
}
|
|
- vf := value.Field(i)
|
|
|
|
- fdump(w, rx, rd+1, ntab, vf)
|
|
|
|
- j++
|
|
|
|
}
|
|
}
|
|
|
|
+ fmt.Fprintf(w, "\n%s}", tab)
|
|
}
|
|
}
|
|
- fmt.Fprintf(w, "\n%s}", tab)
|
|
|
|
} else if value.Kind() == reflect.Slice {
|
|
} else if value.Kind() == reflect.Slice {
|
|
ntab := tab + tabSpace
|
|
ntab := tab + tabSpace
|
|
if value.Type().String() == "[]uint8" {
|
|
if value.Type().String() == "[]uint8" {
|
|
@@ -115,7 +120,9 @@ func fdump(w io.Writer, rx int, rd int, tab string, value reflect.Value) {
|
|
fdump(w, rx, rd+1, ntab, value.MapIndex(kv))
|
|
fdump(w, rx, rd+1, ntab, value.MapIndex(kv))
|
|
}
|
|
}
|
|
fmt.Fprintf(w, "\n%s}%s", tab, "")
|
|
fmt.Fprintf(w, "\n%s}%s", tab, "")
|
|
- } else {
|
|
|
|
|
|
+ } else if !value.IsValid() {
|
|
|
|
+ fmt.Fprint(w, "/* NOT-VALID */")
|
|
|
|
+ } else if value.Type() != nil {
|
|
fmt.Fprintf(w, "undefined /* Type:%s Value:[%v] */", value.Type().String(), value)
|
|
fmt.Fprintf(w, "undefined /* Type:%s Value:[%v] */", value.Type().String(), value)
|
|
}
|
|
}
|
|
}
|
|
}
|