Fix for issue#3 - panic comparing uncomparable types
diff --git a/formatter.go b/formatter.go
index aa334b9..23111ad 100644
--- a/formatter.go
+++ b/formatter.go
@@ -133,7 +133,7 @@
writeByte(w, '}')
case reflect.Struct:
t := v.Type()
- if reflect.DeepEqual(reflect.Zero(t).Interface(), fo.x) {
+ if tryDeepEqual(reflect.Zero(t).Interface(), fo.x) {
if !fo.omit {
io.WriteString(w, t.String())
}
@@ -190,6 +190,11 @@
}
}
+func tryDeepEqual(a, b interface{}) bool {
+ defer func() { recover() }()
+ return reflect.DeepEqual(a, b)
+}
+
func writeByte(w io.Writer, b byte) {
w.Write([]byte{b})
}