From 22147e1e02a440ff7e19f96049195e050bdab88d Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sun, 16 Oct 2022 10:30:59 +0200 Subject: [PATCH] all: Minor cleanups if x { return true } return false => return x fmt.Sprintf("%v", x) => fmt.Sprint(x) or x.String() The fmt.Sprintf idiom is still used in the SecretString tests, where it serves security hardening. --- internal/archiver/testing_test.go | 2 +- internal/cache/file_test.go | 2 +- internal/restic/blob.go | 8 ++------ internal/restic/ids.go | 2 +- internal/restic/tag_list.go | 2 +- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/archiver/testing_test.go b/internal/archiver/testing_test.go index e11b86250..6f6904e3f 100644 --- a/internal/archiver/testing_test.go +++ b/internal/archiver/testing_test.go @@ -217,7 +217,7 @@ func TestTestWalkFiles(t *testing.T) { return err } - got[p] = fmt.Sprintf("%v", item) + got[p] = fmt.Sprint(item) return nil }) diff --git a/internal/cache/file_test.go b/internal/cache/file_test.go index 3e92c1d96..17fc5048f 100644 --- a/internal/cache/file_test.go +++ b/internal/cache/file_test.go @@ -97,7 +97,7 @@ func TestFiles(t *testing.T) { } for _, tpe := range tests { - t.Run(fmt.Sprintf("%v", tpe), func(t *testing.T) { + t.Run(tpe.String(), func(t *testing.T) { ids := generateRandomFiles(t, tpe, c) id := randomID(ids) diff --git a/internal/restic/blob.go b/internal/restic/blob.go index 4ac149adb..260f40fde 100644 --- a/internal/restic/blob.go +++ b/internal/restic/blob.go @@ -114,11 +114,7 @@ func (h BlobHandles) Less(i, j int) bool { continue } - if b < h[j].ID[k] { - return true - } - - return false + return b < h[j].ID[k] } return h[i].Type < h[j].Type @@ -133,5 +129,5 @@ func (h BlobHandles) String() string { for _, e := range h { elements = append(elements, e.String()) } - return fmt.Sprintf("%v", elements) + return fmt.Sprint(elements) } diff --git a/internal/restic/ids.go b/internal/restic/ids.go index cc5ad18da..b3e6b6f22 100644 --- a/internal/restic/ids.go +++ b/internal/restic/ids.go @@ -65,5 +65,5 @@ func (ids IDs) String() string { for _, id := range ids { elements = append(elements, shortID(id)) } - return fmt.Sprintf("%v", elements) + return fmt.Sprint(elements) } diff --git a/internal/restic/tag_list.go b/internal/restic/tag_list.go index 4d57cb14b..b293b14f7 100644 --- a/internal/restic/tag_list.go +++ b/internal/restic/tag_list.go @@ -37,7 +37,7 @@ func (TagList) Type() string { type TagLists []TagList func (l TagLists) String() string { - return fmt.Sprintf("%v", []TagList(l)) + return fmt.Sprint([]TagList(l)) } // Flatten returns the list of all tags provided in TagLists