Improve ConsoleWriter of non-scalar types

This commit is contained in:
Olivier Poitrey 2018-02-13 00:20:42 -08:00
parent 56a970de51
commit a717e7cbed
1 changed files with 8 additions and 1 deletions

View File

@ -75,8 +75,15 @@ func (w ConsoleWriter) Write(p []byte) (n int, err error) {
} else { } else {
buf.WriteString(value) buf.WriteString(value)
} }
default: case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:
fmt.Fprint(buf, value) fmt.Fprint(buf, value)
default:
b, err := json.Marshal(value)
if err != nil {
fmt.Fprintf(buf, "[error: %v]", err)
} else {
fmt.Fprint(buf, string(b))
}
} }
} }
buf.WriteByte('\n') buf.WriteByte('\n')