maintner: compare errors via their public API

The internal representation of the type implementing the error
interface returned by fmt.Errorf may change in new versions of Go,
and reflect.DeepEqual is not suitable for making stable comparisons.

For more complicated comparisons the go-cmp package should be used,
but since we're just comparing two error values, use a simple helper
instead.

Remove insignificant trailing whitespace from Go strings containing
JSON objects.

Fixes golang/go#30442

Change-Id: Iecfb89ebcaf97b49fbe34b4fb17daa7fe70d6a7e
Reviewed-on: https://go-review.googlesource.com/c/164297
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/maintner/github_test.go b/maintner/github_test.go
index 5eb8e1d..de5c3cb 100644
--- a/maintner/github_test.go
+++ b/maintner/github_test.go
@@ -530,7 +530,7 @@
 				"id": 123456,
 				"node_id": "548913adsafas84asdf48a",
 				"user": {
-					"login": "bradfitz", 
+					"login": "bradfitz",
 					"id": 2621
 				},
 				"body": "I approve this commit",
@@ -577,7 +577,7 @@
 				"id": 123456,
 				"node_id": "548913adsafas84asdf48a",
 				"user": {
-					"login": "bradfitz", 
+					"login": "bradfitz",
 					"id": 2621
 				},
 				"body": "I approve this commit",
@@ -739,7 +739,7 @@
 			return nil
 		})
 
-		if !reflect.DeepEqual(tt.wantErr, err) {
+		if !equalError(tt.wantErr, err) {
 			t.Errorf("%s: ForeachReview errs differ. got: %s, want: %s", tt.name, err, tt.wantErr)
 		}
 
@@ -751,6 +751,12 @@
 	t.Log("Tested Reviews")
 }
 
+// equalError reports whether errors a and b are considered equal.
+// They're equal if both are nil, or both are not nil and a.Error() == b.Error().
+func equalError(a, b error) bool {
+	return a == nil && b == nil || a != nil && b != nil && a.Error() == b.Error()
+}
+
 func TestCacheableURL(t *testing.T) {
 	tests := []struct {
 		v    string