From 37113282ca22fa9ab9d781c8c9ae377e73ba6cb0 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 6 Mar 2020 23:27:37 +0100 Subject: [PATCH] Merge a few variable declaration and initializations --- cmd/restic/cmd_snapshots.go | 3 +-- internal/fuse/dir.go | 3 +-- internal/restic/hardlinks_index_test.go | 6 ++---- internal/restic/snapshot_group.go | 4 +--- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go index d92499e30..380b9b75c 100644 --- a/cmd/restic/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -251,9 +251,8 @@ func PrintSnapshots(stdout io.Writer, list restic.Snapshots, reasons []restic.Ke // Prints nothing, if we did not group at all. func PrintSnapshotGroupHeader(stdout io.Writer, groupKeyJSON string) error { var key restic.SnapshotGroupKey - var err error - err = json.Unmarshal([]byte(groupKeyJSON), &key) + err := json.Unmarshal([]byte(groupKeyJSON), &key) if err != nil { return err } diff --git a/internal/fuse/dir.go b/internal/fuse/dir.go index 22530ea49..8ebb63d60 100644 --- a/internal/fuse/dir.go +++ b/internal/fuse/dir.go @@ -125,8 +125,7 @@ func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error { func (d *dir) calcNumberOfLinks() uint32 { // a directory d has 2 hardlinks + the number // of directories contained by d - var count uint32 - count = 2 + count := uint32(2) for _, node := range d.items { if node.Type == "dir" { count++ diff --git a/internal/restic/hardlinks_index_test.go b/internal/restic/hardlinks_index_test.go index 7e4bcd51a..8040d657f 100644 --- a/internal/restic/hardlinks_index_test.go +++ b/internal/restic/hardlinks_index_test.go @@ -15,15 +15,13 @@ func TestHardLinks(t *testing.T) { idx.Add(1, 2, "inode1-file1-on-device2") idx.Add(2, 3, "inode2-file2-on-device3") - var sresult string - sresult = idx.GetFilename(1, 2) + sresult := idx.GetFilename(1, 2) rtest.Equals(t, sresult, "inode1-file1-on-device2") sresult = idx.GetFilename(2, 3) rtest.Equals(t, sresult, "inode2-file2-on-device3") - var bresult bool - bresult = idx.Has(1, 2) + bresult := idx.Has(1, 2) rtest.Equals(t, bresult, true) bresult = idx.Has(1, 3) diff --git a/internal/restic/snapshot_group.go b/internal/restic/snapshot_group.go index bc3ef8ae3..c8b1a5faa 100644 --- a/internal/restic/snapshot_group.go +++ b/internal/restic/snapshot_group.go @@ -25,9 +25,7 @@ func GroupSnapshots(snapshots Snapshots, options string) (map[string]Snapshots, var GroupByTag bool var GroupByHost bool var GroupByPath bool - var GroupOptionList []string - - GroupOptionList = strings.Split(options, ",") + GroupOptionList := strings.Split(options, ",") for _, option := range GroupOptionList { switch option {