From bb84d351f17c76044138ed4b496c60881027522f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 19 Aug 2016 20:45:19 +0200 Subject: [PATCH] Revert "ID: move Str() to non-pointer receiver" This reverts commit f102406cd70cf55a4e2f5874b7201ac8aeb401c7. --- src/restic/backend/id.go | 6 +++++- src/restic/backend/id_int_test.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/restic/backend/id.go b/src/restic/backend/id.go index 6c7bc5321..115792707 100644 --- a/src/restic/backend/id.go +++ b/src/restic/backend/id.go @@ -44,7 +44,11 @@ func (id ID) String() string { const shortStr = 4 // Str returns the shortened string version of id. -func (id ID) Str() string { +func (id *ID) Str() string { + if id == nil { + return "[nil]" + } + if id.IsNull() { return "[null]" } diff --git a/src/restic/backend/id_int_test.go b/src/restic/backend/id_int_test.go index ed84a5a37..d46a1554b 100644 --- a/src/restic/backend/id_int_test.go +++ b/src/restic/backend/id_int_test.go @@ -8,4 +8,9 @@ func TestIDMethods(t *testing.T) { if id.Str() != "[null]" { t.Errorf("ID.Str() returned wrong value, want %v, got %v", "[null]", id.Str()) } + + var pid *ID + if pid.Str() != "[nil]" { + t.Errorf("ID.Str() returned wrong value, want %v, got %v", "[nil]", pid.Str()) + } }