diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 211089253..5aa702ee7 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -1601,7 +1601,7 @@ type appendOnlyBackend struct { } // called via repo.Backend().Remove() -func (b *appendOnlyBackend) Remove(ctx context.Context, h restic.Handle) error { +func (b *appendOnlyBackend) Remove(_ context.Context, h restic.Handle) error { return errors.Errorf("Failed to remove %v", h) } diff --git a/internal/archiver/archiver_test.go b/internal/archiver/archiver_test.go index e3a850591..9be70691f 100644 --- a/internal/archiver/archiver_test.go +++ b/internal/archiver/archiver_test.go @@ -1845,27 +1845,27 @@ type noCancelBackend struct { restic.Backend } -func (c *noCancelBackend) Remove(ctx context.Context, h restic.Handle) error { +func (c *noCancelBackend) Remove(_ context.Context, h restic.Handle) error { return c.Backend.Remove(context.Background(), h) } -func (c *noCancelBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { +func (c *noCancelBackend) Save(_ context.Context, h restic.Handle, rd restic.RewindReader) error { return c.Backend.Save(context.Background(), h, rd) } -func (c *noCancelBackend) Load(ctx context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error { +func (c *noCancelBackend) Load(_ context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error { return c.Backend.Load(context.Background(), h, length, offset, fn) } -func (c *noCancelBackend) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error) { +func (c *noCancelBackend) Stat(_ context.Context, h restic.Handle) (restic.FileInfo, error) { return c.Backend.Stat(context.Background(), h) } -func (c *noCancelBackend) List(ctx context.Context, t restic.FileType, fn func(restic.FileInfo) error) error { +func (c *noCancelBackend) List(_ context.Context, t restic.FileType, fn func(restic.FileInfo) error) error { return c.Backend.List(context.Background(), t, fn) } -func (c *noCancelBackend) Delete(ctx context.Context) error { +func (c *noCancelBackend) Delete(_ context.Context) error { return c.Backend.Delete(context.Background()) } diff --git a/internal/archiver/blob_saver_test.go b/internal/archiver/blob_saver_test.go index 367b7be8b..e0ec8e11a 100644 --- a/internal/archiver/blob_saver_test.go +++ b/internal/archiver/blob_saver_test.go @@ -22,7 +22,7 @@ type saveFail struct { failAt int32 } -func (b *saveFail) SaveBlob(ctx context.Context, t restic.BlobType, buf []byte, id restic.ID, storeDuplicates bool) (restic.ID, bool, int, error) { +func (b *saveFail) SaveBlob(_ context.Context, t restic.BlobType, buf []byte, id restic.ID, storeDuplicates bool) (restic.ID, bool, int, error) { val := atomic.AddInt32(&b.cnt, 1) if val == b.failAt { return restic.ID{}, false, 0, errTest diff --git a/internal/archiver/tree_saver_test.go b/internal/archiver/tree_saver_test.go index 7cc53346c..383174de6 100644 --- a/internal/archiver/tree_saver_test.go +++ b/internal/archiver/tree_saver_test.go @@ -12,7 +12,7 @@ import ( "golang.org/x/sync/errgroup" ) -func treeSaveHelper(ctx context.Context, t restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) { +func treeSaveHelper(_ context.Context, t restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) { cb(SaveBlobResponse{ id: restic.NewRandomID(), known: false, diff --git a/internal/backend/azure/azure.go b/internal/backend/azure/azure.go index 9a3695f0f..57bef4b22 100644 --- a/internal/backend/azure/azure.go +++ b/internal/backend/azure/azure.go @@ -108,7 +108,7 @@ func open(cfg Config, rt http.RoundTripper) (*Backend, error) { } // Open opens the Azure backend at specified container. -func Open(ctx context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) { +func Open(_ context.Context, cfg Config, rt http.RoundTripper) (*Backend, error) { return open(cfg, rt) } diff --git a/internal/backend/dryrun/dry_backend.go b/internal/backend/dryrun/dry_backend.go index 487e2bc33..f7acb10dd 100644 --- a/internal/backend/dryrun/dry_backend.go +++ b/internal/backend/dryrun/dry_backend.go @@ -28,7 +28,7 @@ func New(be restic.Backend) *Backend { } // Save adds new Data to the backend. -func (be *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { +func (be *Backend) Save(_ context.Context, h restic.Handle, _ restic.RewindReader) error { if err := h.Valid(); err != nil { return err } @@ -38,7 +38,7 @@ func (be *Backend) Save(ctx context.Context, h restic.Handle, rd restic.RewindRe } // Remove deletes a file from the backend. -func (be *Backend) Remove(ctx context.Context, h restic.Handle) error { +func (be *Backend) Remove(_ context.Context, _ restic.Handle) error { return nil } @@ -52,7 +52,7 @@ func (be *Backend) Location() string { } // Delete removes all data in the backend. -func (be *Backend) Delete(ctx context.Context) error { +func (be *Backend) Delete(_ context.Context) error { return nil } diff --git a/internal/backend/layout/layout.go b/internal/backend/layout/layout.go index 14fb8dcdc..b83f4c05b 100644 --- a/internal/backend/layout/layout.go +++ b/internal/backend/layout/layout.go @@ -37,7 +37,7 @@ type LocalFilesystem struct { } // ReadDir returns all entries of a directory. -func (l *LocalFilesystem) ReadDir(ctx context.Context, dir string) ([]os.FileInfo, error) { +func (l *LocalFilesystem) ReadDir(_ context.Context, dir string) ([]os.FileInfo, error) { f, err := fs.Open(dir) if err != nil { return nil, err diff --git a/internal/backend/local/local.go b/internal/backend/local/local.go index ca806f754..be332e8ad 100644 --- a/internal/backend/local/local.go +++ b/internal/backend/local/local.go @@ -105,7 +105,7 @@ func (b *Local) IsNotExist(err error) bool { } // Save stores data in the backend at the handle. -func (b *Local) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) (err error) { +func (b *Local) Save(_ context.Context, h restic.Handle, rd restic.RewindReader) (err error) { finalname := b.Filename(h) dir := filepath.Dir(finalname) @@ -200,7 +200,7 @@ func (b *Local) Load(ctx context.Context, h restic.Handle, length int, offset in return backend.DefaultLoad(ctx, h, length, offset, b.openReader, fn) } -func (b *Local) openReader(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) { +func (b *Local) openReader(_ context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) { f, err := fs.Open(b.Filename(h)) if err != nil { return nil, err @@ -222,7 +222,7 @@ func (b *Local) openReader(ctx context.Context, h restic.Handle, length int, off } // Stat returns information about a blob. -func (b *Local) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error) { +func (b *Local) Stat(_ context.Context, h restic.Handle) (restic.FileInfo, error) { fi, err := fs.Stat(b.Filename(h)) if err != nil { return restic.FileInfo{}, errors.WithStack(err) @@ -232,7 +232,7 @@ func (b *Local) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, err } // Remove removes the blob with the given name and type. -func (b *Local) Remove(ctx context.Context, h restic.Handle) error { +func (b *Local) Remove(_ context.Context, h restic.Handle) error { fn := b.Filename(h) // reset read-only flag @@ -339,7 +339,7 @@ func visitFiles(ctx context.Context, dir string, fn func(restic.FileInfo) error, } // Delete removes the repository and all files. -func (b *Local) Delete(ctx context.Context) error { +func (b *Local) Delete(_ context.Context) error { return fs.RemoveAll(b.Path) } diff --git a/internal/backend/rest/rest_test.go b/internal/backend/rest/rest_test.go index a473e4440..9d7073bc5 100644 --- a/internal/backend/rest/rest_test.go +++ b/internal/backend/rest/rest_test.go @@ -67,7 +67,7 @@ func runRESTServer(ctx context.Context, t testing.TB, dir string) (*url.URL, fun return url, cleanup } -func newTestSuite(ctx context.Context, t testing.TB, url *url.URL, minimalData bool) *test.Suite { +func newTestSuite(_ context.Context, t testing.TB, url *url.URL, minimalData bool) *test.Suite { tr, err := backend.Transport(backend.TransportOptions{}) if err != nil { t.Fatalf("cannot create transport for tests: %v", err) diff --git a/internal/backend/sftp/sftp.go b/internal/backend/sftp/sftp.go index e97a5f9c8..12c355003 100644 --- a/internal/backend/sftp/sftp.go +++ b/internal/backend/sftp/sftp.go @@ -187,7 +187,7 @@ func (r *SFTP) Join(p ...string) string { } // ReadDir returns the entries for a directory. -func (r *SFTP) ReadDir(ctx context.Context, dir string) ([]os.FileInfo, error) { +func (r *SFTP) ReadDir(_ context.Context, dir string) ([]os.FileInfo, error) { fi, err := r.c.ReadDir(dir) // sftp client does not specify dir name on error, so add it here @@ -296,7 +296,7 @@ func tempSuffix() string { } // Save stores data in the backend at the handle. -func (r *SFTP) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { +func (r *SFTP) Save(_ context.Context, h restic.Handle, rd restic.RewindReader) error { if err := r.clientError(); err != nil { return err } @@ -400,7 +400,7 @@ func (r *SFTP) Load(ctx context.Context, h restic.Handle, length int, offset int return backend.DefaultLoad(ctx, h, length, offset, r.openReader, fn) } -func (r *SFTP) openReader(ctx context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) { +func (r *SFTP) openReader(_ context.Context, h restic.Handle, length int, offset int64) (io.ReadCloser, error) { f, err := r.c.Open(r.Filename(h)) if err != nil { return nil, err @@ -424,7 +424,7 @@ func (r *SFTP) openReader(ctx context.Context, h restic.Handle, length int, offs } // Stat returns information about a blob. -func (r *SFTP) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, error) { +func (r *SFTP) Stat(_ context.Context, h restic.Handle) (restic.FileInfo, error) { if err := r.clientError(); err != nil { return restic.FileInfo{}, err } @@ -438,7 +438,7 @@ func (r *SFTP) Stat(ctx context.Context, h restic.Handle) (restic.FileInfo, erro } // Remove removes the content stored at name. -func (r *SFTP) Remove(ctx context.Context, h restic.Handle) error { +func (r *SFTP) Remove(_ context.Context, h restic.Handle) error { if err := r.clientError(); err != nil { return err } diff --git a/internal/cache/backend_test.go b/internal/cache/backend_test.go index 3ddab5952..930d853b2 100644 --- a/internal/cache/backend_test.go +++ b/internal/cache/backend_test.go @@ -118,7 +118,7 @@ type loadErrorBackend struct { loadError error } -func (be loadErrorBackend) Load(ctx context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error { +func (be loadErrorBackend) Load(_ context.Context, _ restic.Handle, _ int, _ int64, _ func(rd io.Reader) error) error { time.Sleep(10 * time.Millisecond) return be.loadError } diff --git a/internal/fuse/dir.go b/internal/fuse/dir.go index 3d12d263b..7dc157b7e 100644 --- a/internal/fuse/dir.go +++ b/internal/fuse/dir.go @@ -120,7 +120,7 @@ func (d *dir) open(ctx context.Context) error { return nil } -func (d *dir) Attr(ctx context.Context, a *fuse.Attr) error { +func (d *dir) Attr(_ context.Context, a *fuse.Attr) error { debug.Log("Attr()") a.Inode = d.inode a.Mode = os.ModeDir | d.node.Mode @@ -221,7 +221,7 @@ func (d *dir) Lookup(ctx context.Context, name string) (fs.Node, error) { } } -func (d *dir) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error { +func (d *dir) Listxattr(_ context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error { debug.Log("Listxattr(%v, %v)", d.node.Name, req.Size) for _, attr := range d.node.ExtendedAttributes { resp.Append(attr.Name) @@ -229,7 +229,7 @@ func (d *dir) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *f return nil } -func (d *dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error { +func (d *dir) Getxattr(_ context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error { debug.Log("Getxattr(%v, %v, %v)", d.node.Name, req.Name, req.Size) attrval := d.node.GetExtendedAttribute(req.Name) if attrval != nil { diff --git a/internal/fuse/file.go b/internal/fuse/file.go index 35bc2a73e..9fa2d4c00 100644 --- a/internal/fuse/file.go +++ b/internal/fuse/file.go @@ -45,7 +45,7 @@ func newFile(root *Root, inode uint64, node *restic.Node) (fusefile *file, err e }, nil } -func (f *file) Attr(ctx context.Context, a *fuse.Attr) error { +func (f *file) Attr(_ context.Context, a *fuse.Attr) error { debug.Log("Attr(%v)", f.node.Name) a.Inode = f.inode a.Mode = f.node.Mode @@ -66,7 +66,7 @@ func (f *file) Attr(ctx context.Context, a *fuse.Attr) error { } -func (f *file) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { +func (f *file) Open(_ context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { debug.Log("open file %v with %d blobs", f.node.Name, len(f.node.Content)) var bytes uint64 @@ -166,7 +166,7 @@ func (f *openFile) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.R return nil } -func (f *file) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error { +func (f *file) Listxattr(_ context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error { debug.Log("Listxattr(%v, %v)", f.node.Name, req.Size) for _, attr := range f.node.ExtendedAttributes { resp.Append(attr.Name) @@ -174,7 +174,7 @@ func (f *file) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp * return nil } -func (f *file) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error { +func (f *file) Getxattr(_ context.Context, req *fuse.GetxattrRequest, resp *fuse.GetxattrResponse) error { debug.Log("Getxattr(%v, %v, %v)", f.node.Name, req.Name, req.Size) attrval := f.node.GetExtendedAttribute(req.Name) if attrval != nil { diff --git a/internal/fuse/link.go b/internal/fuse/link.go index 47ee666a3..9d68fd549 100644 --- a/internal/fuse/link.go +++ b/internal/fuse/link.go @@ -24,11 +24,11 @@ func newLink(root *Root, inode uint64, node *restic.Node) (*link, error) { return &link{root: root, inode: inode, node: node}, nil } -func (l *link) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *link) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { return l.node.LinkTarget, nil } -func (l *link) Attr(ctx context.Context, a *fuse.Attr) error { +func (l *link) Attr(_ context.Context, a *fuse.Attr) error { a.Inode = l.inode a.Mode = l.node.Mode diff --git a/internal/fuse/other.go b/internal/fuse/other.go index 1a78403a7..2ca80b505 100644 --- a/internal/fuse/other.go +++ b/internal/fuse/other.go @@ -20,11 +20,11 @@ func newOther(root *Root, inode uint64, node *restic.Node) (*other, error) { return &other{root: root, inode: inode, node: node}, nil } -func (l *other) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *other) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { return l.node.LinkTarget, nil } -func (l *other) Attr(ctx context.Context, a *fuse.Attr) error { +func (l *other) Attr(_ context.Context, a *fuse.Attr) error { a.Inode = l.inode a.Mode = l.node.Mode diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index 6d18a084b..219cb136e 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -42,7 +42,7 @@ func NewSnapshotsDir(root *Root, inode, parentInode uint64, dirStruct *Snapshots } // Attr returns the attributes for any dir in the snapshots directory structure -func (d *SnapshotsDir) Attr(ctx context.Context, attr *fuse.Attr) error { +func (d *SnapshotsDir) Attr(_ context.Context, attr *fuse.Attr) error { attr.Inode = d.inode attr.Mode = os.ModeDir | 0555 attr.Uid = d.root.uid @@ -134,12 +134,12 @@ func newSnapshotLink(root *Root, inode uint64, target string, snapshot *restic.S } // Readlink -func (l *snapshotLink) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *snapshotLink) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { return l.target, nil } // Attr -func (l *snapshotLink) Attr(ctx context.Context, a *fuse.Attr) error { +func (l *snapshotLink) Attr(_ context.Context, a *fuse.Attr) error { a.Inode = l.inode a.Mode = os.ModeSymlink | 0777 a.Size = uint64(len(l.target)) diff --git a/internal/migrations/s3_layout.go b/internal/migrations/s3_layout.go index a5293ef16..78d2492d8 100644 --- a/internal/migrations/s3_layout.go +++ b/internal/migrations/s3_layout.go @@ -39,7 +39,7 @@ func toS3Backend(b restic.Backend) *s3.Backend { } // Check tests whether the migration can be applied. -func (m *S3Layout) Check(ctx context.Context, repo restic.Repository) (bool, string, error) { +func (m *S3Layout) Check(_ context.Context, repo restic.Repository) (bool, string, error) { be := toS3Backend(repo.Backend()) if be == nil { debug.Log("backend is not s3") diff --git a/internal/migrations/upgrade_repo_v2.go b/internal/migrations/upgrade_repo_v2.go index 43a6cd91c..a81abc0e3 100644 --- a/internal/migrations/upgrade_repo_v2.go +++ b/internal/migrations/upgrade_repo_v2.go @@ -44,7 +44,7 @@ func (*UpgradeRepoV2) Desc() string { return "upgrade a repository to version 2" } -func (*UpgradeRepoV2) Check(ctx context.Context, repo restic.Repository) (bool, string, error) { +func (*UpgradeRepoV2) Check(_ context.Context, repo restic.Repository) (bool, string, error) { isV1 := repo.Config().Version == 1 reason := "" if !isV1 { diff --git a/internal/restic/config_test.go b/internal/restic/config_test.go index 759788f6b..5a7f6b0ae 100644 --- a/internal/restic/config_test.go +++ b/internal/restic/config_test.go @@ -12,7 +12,7 @@ type saver struct { fn func(restic.FileType, []byte) (restic.ID, error) } -func (s saver) SaveUnpacked(ctx context.Context, t restic.FileType, buf []byte) (restic.ID, error) { +func (s saver) SaveUnpacked(_ context.Context, t restic.FileType, buf []byte) (restic.ID, error) { return s.fn(t, buf) } @@ -24,7 +24,7 @@ type loader struct { fn func(restic.FileType, restic.ID) ([]byte, error) } -func (l loader) LoadUnpacked(ctx context.Context, t restic.FileType, id restic.ID) (data []byte, err error) { +func (l loader) LoadUnpacked(_ context.Context, t restic.FileType, id restic.ID) (data []byte, err error) { return l.fn(t, id) } diff --git a/internal/walker/rewriter_test.go b/internal/walker/rewriter_test.go index 07ce5f72f..716217ac6 100644 --- a/internal/walker/rewriter_test.go +++ b/internal/walker/rewriter_test.go @@ -15,7 +15,7 @@ type WritableTreeMap struct { TreeMap } -func (t WritableTreeMap) SaveBlob(ctx context.Context, tpe restic.BlobType, buf []byte, id restic.ID, storeDuplicate bool) (newID restic.ID, known bool, size int, err error) { +func (t WritableTreeMap) SaveBlob(_ context.Context, tpe restic.BlobType, buf []byte, id restic.ID, _ bool) (newID restic.ID, known bool, size int, err error) { if tpe != restic.TreeBlob { return restic.ID{}, false, 0, errors.New("can only save trees") } diff --git a/internal/walker/walker_test.go b/internal/walker/walker_test.go index 8de1a9dc4..54cc69792 100644 --- a/internal/walker/walker_test.go +++ b/internal/walker/walker_test.go @@ -76,7 +76,7 @@ func buildTreeMap(tree TestTree, m TreeMap) restic.ID { // TreeMap returns the trees from the map on LoadTree. type TreeMap map[restic.ID][]byte -func (t TreeMap) LoadBlob(ctx context.Context, tpe restic.BlobType, id restic.ID, buf []byte) ([]byte, error) { +func (t TreeMap) LoadBlob(_ context.Context, tpe restic.BlobType, id restic.ID, _ []byte) ([]byte, error) { if tpe != restic.TreeBlob { return nil, errors.New("can only load trees") }