diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go index 6f633b32c..11c048f90 100644 --- a/cmd/restic/integration_test.go +++ b/cmd/restic/integration_test.go @@ -1181,7 +1181,7 @@ type emptySaveBackend struct { restic.Backend } -func (b *emptySaveBackend) Save(ctx context.Context, h restic.Handle, rd restic.RewindReader) error { +func (b *emptySaveBackend) Save(ctx context.Context, h restic.Handle, _ restic.RewindReader) error { return b.Backend.Save(ctx, h, restic.NewByteReader([]byte{}, nil)) } @@ -2202,7 +2202,7 @@ type writeToOnly struct { rd io.Reader } -func (r *writeToOnly) Read(p []byte) (n int, err error) { +func (r *writeToOnly) Read(_ []byte) (n int, err error) { return 0, fmt.Errorf("should have called WriteTo instead") } diff --git a/internal/archiver/blob_saver_test.go b/internal/archiver/blob_saver_test.go index e0ec8e11a..1996c35b8 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(_ context.Context, t restic.BlobType, buf []byte, id restic.ID, storeDuplicates bool) (restic.ID, bool, int, error) { +func (b *saveFail) SaveBlob(_ context.Context, _ restic.BlobType, _ []byte, id restic.ID, _ 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 383174de6..5de4375d6 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(_ context.Context, t restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) { +func treeSaveHelper(_ context.Context, _ restic.BlobType, buf *Buffer, cb func(res SaveBlobResponse)) { cb(SaveBlobResponse{ id: restic.NewRandomID(), known: false, diff --git a/internal/backend/utils_test.go b/internal/backend/utils_test.go index 16995afd3..8392bfa8f 100644 --- a/internal/backend/utils_test.go +++ b/internal/backend/utils_test.go @@ -154,7 +154,7 @@ type mockReader struct { closed bool } -func (rd *mockReader) Read(p []byte) (n int, err error) { +func (rd *mockReader) Read(_ []byte) (n int, err error) { return 0, nil } func (rd *mockReader) Close() error { diff --git a/internal/crypto/crypto.go b/internal/crypto/crypto.go index 56ee61dba..752d886e3 100644 --- a/internal/crypto/crypto.go +++ b/internal/crypto/crypto.go @@ -322,7 +322,7 @@ func (k *Key) Seal(dst, nonce, plaintext, additionalData []byte) []byte { // // Even if the function fails, the contents of dst, up to its capacity, // may be overwritten. -func (k *Key) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { +func (k *Key) Open(dst, nonce, ciphertext, _ []byte) ([]byte, error) { if !k.Valid() { return nil, errors.New("invalid key") } diff --git a/internal/fs/fs_reader.go b/internal/fs/fs_reader.go index 1551ad919..47af74245 100644 --- a/internal/fs/fs_reader.go +++ b/internal/fs/fs_reader.go @@ -35,7 +35,7 @@ var _ FS = &Reader{} // VolumeName returns leading volume name, for the Reader file system it's // always the empty string. -func (fs *Reader) VolumeName(path string) string { +func (fs *Reader) VolumeName(_ string) string { return "" } @@ -76,7 +76,7 @@ func (fs *Reader) fi() os.FileInfo { // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, // methods on the returned File can be used for I/O. // If there is an error, it will be of type *os.PathError. -func (fs *Reader) OpenFile(name string, flag int, perm os.FileMode) (f File, err error) { +func (fs *Reader) OpenFile(name string, flag int, _ os.FileMode) (f File, err error) { if flag & ^(O_RDONLY|O_NOFOLLOW) != 0 { return nil, pathError("open", name, fmt.Errorf("invalid combination of flags 0x%x", flag)) @@ -149,7 +149,7 @@ func (fs *Reader) Separator() string { } // IsAbs reports whether the path is absolute. For the Reader, this is always the case. -func (fs *Reader) IsAbs(p string) bool { +func (fs *Reader) IsAbs(_ string) bool { return true } @@ -236,11 +236,11 @@ func (f fakeFile) Fd() uintptr { return 0 } -func (f fakeFile) Readdirnames(n int) ([]string, error) { +func (f fakeFile) Readdirnames(_ int) ([]string, error) { return nil, pathError("readdirnames", f.name, os.ErrInvalid) } -func (f fakeFile) Readdir(n int) ([]os.FileInfo, error) { +func (f fakeFile) Readdir(_ int) ([]os.FileInfo, error) { return nil, pathError("readdir", f.name, os.ErrInvalid) } @@ -248,7 +248,7 @@ func (f fakeFile) Seek(int64, int) (int64, error) { return 0, pathError("seek", f.name, os.ErrInvalid) } -func (f fakeFile) Read(p []byte) (int, error) { +func (f fakeFile) Read(_ []byte) (int, error) { return 0, pathError("read", f.name, os.ErrInvalid) } diff --git a/internal/fs/vss.go b/internal/fs/vss.go index 9995f2d3e..5f0ea36d9 100644 --- a/internal/fs/vss.go +++ b/internal/fs/vss.go @@ -34,7 +34,7 @@ func HasSufficientPrivilegesForVSS() error { // NewVssSnapshot creates a new vss snapshot. If creating the snapshots doesn't // finish within the timeout an error is returned. func NewVssSnapshot( - volume string, timeoutInSeconds uint, msgError ErrorHandler) (VssSnapshot, error) { + _ string, _ uint, _ ErrorHandler) (VssSnapshot, error) { return VssSnapshot{}, errors.New("VSS snapshots are only supported on windows") } diff --git a/internal/fuse/file.go b/internal/fuse/file.go index 9fa2d4c00..fd9d8ccc2 100644 --- a/internal/fuse/file.go +++ b/internal/fuse/file.go @@ -66,7 +66,7 @@ func (f *file) Attr(_ context.Context, a *fuse.Attr) error { } -func (f *file) Open(_ context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { +func (f *file) Open(_ context.Context, _ *fuse.OpenRequest, _ *fuse.OpenResponse) (fs.Handle, error) { debug.Log("open file %v with %d blobs", f.node.Name, len(f.node.Content)) var bytes uint64 diff --git a/internal/fuse/link.go b/internal/fuse/link.go index 9d68fd549..c89451602 100644 --- a/internal/fuse/link.go +++ b/internal/fuse/link.go @@ -24,7 +24,7 @@ func newLink(root *Root, inode uint64, node *restic.Node) (*link, error) { return &link{root: root, inode: inode, node: node}, nil } -func (l *link) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *link) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) { return l.node.LinkTarget, nil } diff --git a/internal/fuse/other.go b/internal/fuse/other.go index 2ca80b505..f536de5c1 100644 --- a/internal/fuse/other.go +++ b/internal/fuse/other.go @@ -20,7 +20,7 @@ func newOther(root *Root, inode uint64, node *restic.Node) (*other, error) { return &other{root: root, inode: inode, node: node}, nil } -func (l *other) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *other) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) { return l.node.LinkTarget, nil } diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index 219cb136e..61df3ad08 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -134,7 +134,7 @@ func newSnapshotLink(root *Root, inode uint64, target string, snapshot *restic.S } // Readlink -func (l *snapshotLink) Readlink(_ context.Context, req *fuse.ReadlinkRequest) (string, error) { +func (l *snapshotLink) Readlink(_ context.Context, _ *fuse.ReadlinkRequest) (string, error) { return l.target, nil } diff --git a/internal/restic/find_test.go b/internal/restic/find_test.go index f5e288b9d..234561b6d 100644 --- a/internal/restic/find_test.go +++ b/internal/restic/find_test.go @@ -166,7 +166,7 @@ func (r ForbiddenRepo) LoadBlob(context.Context, restic.BlobType, restic.ID, []b return nil, errors.New("should not be called") } -func (r ForbiddenRepo) LookupBlobSize(id restic.ID, tpe restic.BlobType) (uint, bool) { +func (r ForbiddenRepo) LookupBlobSize(_ restic.ID, _ restic.BlobType) (uint, bool) { return 0, false } diff --git a/internal/restic/snapshot_policy.go b/internal/restic/snapshot_policy.go index 228e4c88a..bec594707 100644 --- a/internal/restic/snapshot_policy.go +++ b/internal/restic/snapshot_policy.go @@ -136,7 +136,7 @@ func y(d time.Time, _ int) int { } // always returns a unique number for d. -func always(d time.Time, nr int) int { +func always(_ time.Time, nr int) int { return nr } diff --git a/internal/restorer/restorer_unix_test.go b/internal/restorer/restorer_unix_test.go index 904f26359..2c30a6b64 100644 --- a/internal/restorer/restorer_unix_test.go +++ b/internal/restorer/restorer_unix_test.go @@ -73,9 +73,9 @@ type printerMock struct { filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64 } -func (p *printerMock) Update(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { +func (p *printerMock) Update(_, _, _, _ uint64, _ time.Duration) { } -func (p *printerMock) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { +func (p *printerMock) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, _ time.Duration) { p.filesFinished = filesFinished p.filesTotal = filesTotal p.allBytesWritten = allBytesWritten diff --git a/internal/selfupdate/download_unix.go b/internal/selfupdate/download_unix.go index c6189e9d9..bc1762948 100644 --- a/internal/selfupdate/download_unix.go +++ b/internal/selfupdate/download_unix.go @@ -4,7 +4,7 @@ package selfupdate // Remove the target binary. -func removeResticBinary(dir, target string) error { +func removeResticBinary(_, _ string) error { // removed on rename on this platform return nil } diff --git a/internal/ui/backup/text.go b/internal/ui/backup/text.go index acb2a8d3a..553f559d4 100644 --- a/internal/ui/backup/text.go +++ b/internal/ui/backup/text.go @@ -72,13 +72,13 @@ func (b *TextProgress) Update(total, processed Counter, errors uint, currentFile // ScannerError is the error callback function for the scanner, it prints the // error in verbose mode and returns nil. -func (b *TextProgress) ScannerError(item string, err error) error { +func (b *TextProgress) ScannerError(_ string, err error) error { b.V("scan: %v\n", err) return nil } // Error is the error callback function for the archiver, it prints the error and returns nil. -func (b *TextProgress) Error(item string, err error) error { +func (b *TextProgress) Error(_ string, err error) error { b.E("error: %v\n", err) return nil } @@ -126,7 +126,7 @@ func (b *TextProgress) Reset() { } // Finish prints the finishing messages. -func (b *TextProgress) Finish(snapshotID restic.ID, start time.Time, summary *Summary, dryRun bool) { +func (b *TextProgress) Finish(_ restic.ID, start time.Time, summary *Summary, dryRun bool) { b.P("\n") b.P("Files: %5d new, %5d changed, %5d unmodified\n", summary.Files.New, summary.Files.Changed, summary.Files.Unchanged) b.P("Dirs: %5d new, %5d changed, %5d unmodified\n", summary.Dirs.New, summary.Dirs.Changed, summary.Dirs.Unchanged) diff --git a/internal/ui/restore/progressformatter_test.go b/internal/ui/restore/progressformatter_test.go index 0cc4ea1ba..e3dc3ace5 100644 --- a/internal/ui/restore/progressformatter_test.go +++ b/internal/ui/restore/progressformatter_test.go @@ -25,7 +25,7 @@ const mockFinishDuration = 42 * time.Second func (p *mockPrinter) Update(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, duration, false}) } -func (p *mockPrinter) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, duration time.Duration) { +func (p *mockPrinter) Finish(filesFinished, filesTotal, allBytesWritten, allBytesTotal uint64, _ time.Duration) { p.trace = append(p.trace, printerTraceEntry{filesFinished, filesTotal, allBytesWritten, allBytesTotal, mockFinishDuration, true}) } diff --git a/internal/ui/termstatus/terminal_posix.go b/internal/ui/termstatus/terminal_posix.go index c16a2d989..ca5468f45 100644 --- a/internal/ui/termstatus/terminal_posix.go +++ b/internal/ui/termstatus/terminal_posix.go @@ -15,7 +15,7 @@ const ( // posixClearCurrentLine removes all characters from the current line and resets the // cursor position to the first column. -func posixClearCurrentLine(wr io.Writer, fd uintptr) { +func posixClearCurrentLine(wr io.Writer, _ uintptr) { // clear current line _, err := wr.Write([]byte(posixControlMoveCursorHome + posixControlClearLine)) if err != nil { @@ -25,7 +25,7 @@ func posixClearCurrentLine(wr io.Writer, fd uintptr) { } // posixMoveCursorUp moves the cursor to the line n lines above the current one. -func posixMoveCursorUp(wr io.Writer, fd uintptr, n int) { +func posixMoveCursorUp(wr io.Writer, _ uintptr, n int) { data := []byte(posixControlMoveCursorHome) data = append(data, bytes.Repeat([]byte(posixControlMoveCursorUp), n)...) _, err := wr.Write(data) diff --git a/internal/ui/termstatus/terminal_windows.go b/internal/ui/termstatus/terminal_windows.go index d1358c022..c7919a7b7 100644 --- a/internal/ui/termstatus/terminal_windows.go +++ b/internal/ui/termstatus/terminal_windows.go @@ -45,7 +45,7 @@ var ( // windowsClearCurrentLine removes all characters from the current line and // resets the cursor position to the first column. -func windowsClearCurrentLine(wr io.Writer, fd uintptr) { +func windowsClearCurrentLine(_ io.Writer, fd uintptr) { var info windows.ConsoleScreenBufferInfo windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info) @@ -61,7 +61,7 @@ func windowsClearCurrentLine(wr io.Writer, fd uintptr) { } // windowsMoveCursorUp moves the cursor to the line n lines above the current one. -func windowsMoveCursorUp(wr io.Writer, fd uintptr, n int) { +func windowsMoveCursorUp(_ io.Writer, fd uintptr, n int) { var info windows.ConsoleScreenBufferInfo windows.GetConsoleScreenBufferInfo(windows.Handle(fd), &info)