Add errors.go

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-05-16 11:53:15 -04:00
parent 17b220b13c
commit 9d8e731294
3 changed files with 88 additions and 73 deletions
+8
View File
@@ -7,6 +7,8 @@ import (
"reflect"
)
var timestampType = reflect.TypeOf(Timestamp{})
// String is a helper routine that allocates a new string value
// to store v and returns a pointer to it.
func String(v string) *string {
@@ -91,6 +93,12 @@ func stringifyStruct(w io.Writer, v reflect.Value) {
_, _ = w.Write([]byte(v.Type().String()))
}
// special handling of Timestamp values
if v.Type() == timestampType {
fmt.Fprintf(w, "{%s}", v.Interface())
return
}
_, _ = w.Write([]byte{'{'})
var sep bool