diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go
index 04f2df367..fb81aa22e 100644
--- a/cmd/restic/cmd_backup.go
+++ b/cmd/restic/cmd_backup.go
@@ -181,7 +181,7 @@ var ErrNoSourceData = errors.Fatal("all source directories/files do not exist")
// filterExisting returns the items that exist and can be accessed. It returns
// ErrNoSourceData if none remain, or ErrInvalidSourceData if some were skipped.
-func filterExisting(items []string, warnf func(msg string, args ...interface{})) (result []string, err error) {
+func filterExisting(items []string, warnf func(msg string, args ...any)) (result []string, err error) {
for _, item := range items {
_, err := fs.Lstat(item)
if err != nil {
@@ -332,7 +332,7 @@ func (opts BackupOptions) Check(gopts global.Options, args []string) error {
// collectRejectByNameFuncs returns a list of all functions which may reject data
// from being saved in a snapshot based on path only
-func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, warnf func(msg string, args ...interface{})) (fs []archiver.RejectByNameFunc, err error) {
+func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, warnf func(msg string, args ...any)) (fs []archiver.RejectByNameFunc, err error) {
// exclude restic cache
if repo.Cache() != nil {
f, err := rejectResticCache(repo)
@@ -356,7 +356,7 @@ func collectRejectByNameFuncs(opts BackupOptions, repo *repository.Repository, w
// collectRejectFuncs returns a list of all functions which may reject data
// from being saved in a snapshot based on path and file info
-func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS, warnf func(msg string, args ...interface{})) (funcs []archiver.RejectFunc, err error) {
+func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS, warnf func(msg string, args ...any)) (funcs []archiver.RejectFunc, err error) {
// allowed devices
if opts.ExcludeOtherFS && !opts.Stdin && !opts.StdinCommand {
f, err := archiver.RejectByDevice(targets, fs)
@@ -404,7 +404,7 @@ func collectRejectFuncs(opts BackupOptions, targets []string, fs fs.FS, warnf fu
}
// collectTargets returns a list of target files/dirs from several sources.
-func collectTargets(opts BackupOptions, args []string, warnf func(msg string, args ...interface{}), stdin io.ReadCloser) (targets []string, err error) {
+func collectTargets(opts BackupOptions, args []string, warnf func(msg string, args ...any), stdin io.ReadCloser) (targets []string, err error) {
if opts.Stdin || opts.StdinCommand {
return nil, nil
}
@@ -589,7 +589,7 @@ func runBackup(ctx context.Context, opts BackupOptions, gopts global.Options, te
_ = progressReporter.Error(item, err)
}
- messageHandler := func(msg string, args ...interface{}) {
+ messageHandler := func(msg string, args ...any) {
if !gopts.JSON {
printer.P(msg, args...)
}
diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go
index b0238c0a1..a88649f20 100644
--- a/cmd/restic/cmd_check.go
+++ b/cmd/restic/cmd_check.go
@@ -570,15 +570,15 @@ func (*jsonErrorPrinter) NewCounterTerminalOnly(_ string) restic.Counter {
return restic.NoopCounter
}
-func (p *jsonErrorPrinter) E(msg string, args ...interface{}) {
+func (p *jsonErrorPrinter) E(msg string, args ...any) {
status := checkError{
MessageType: "error",
Message: fmt.Sprintf(msg, args...),
}
p.term.Error(ui.ToJSONString(status))
}
-func (*jsonErrorPrinter) S(_ string, _ ...interface{}) {}
-func (*jsonErrorPrinter) P(_ string, _ ...interface{}) {}
-func (*jsonErrorPrinter) PT(_ string, _ ...interface{}) {}
-func (*jsonErrorPrinter) V(_ string, _ ...interface{}) {}
-func (*jsonErrorPrinter) VV(_ string, _ ...interface{}) {}
+func (*jsonErrorPrinter) S(_ string, _ ...any) {}
+func (*jsonErrorPrinter) P(_ string, _ ...any) {}
+func (*jsonErrorPrinter) PT(_ string, _ ...any) {}
+func (*jsonErrorPrinter) V(_ string, _ ...any) {}
+func (*jsonErrorPrinter) VV(_ string, _ ...any) {}
diff --git a/cmd/restic/cmd_diff.go b/cmd/restic/cmd_diff.go
index bfecee989..1519b37c7 100644
--- a/cmd/restic/cmd_diff.go
+++ b/cmd/restic/cmd_diff.go
@@ -84,7 +84,7 @@ type Comparer struct {
repo restic.BlobLoader
opts DiffOptions
printChange func(change *Change)
- printError func(string, ...interface{})
+ printError func(string, ...any)
}
type Change struct {
@@ -158,7 +158,7 @@ type DiffStatsContainer struct {
}
// updateBlobs updates the blob counters in the stats struct.
-func updateBlobs(repo restic.Loader, blobs restic.AssociatedBlobSet, stats *DiffStat, printError func(string, ...interface{})) {
+func updateBlobs(repo restic.Loader, blobs restic.AssociatedBlobSet, stats *DiffStat, printError func(string, ...any)) {
for h := range blobs.Keys() {
switch h.Type {
case restic.DataBlob:
diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go
index 8dbe35160..e66cfe939 100644
--- a/cmd/restic/cmd_find.go
+++ b/cmd/restic/cmd_find.go
@@ -136,9 +136,9 @@ type statefulOutput struct {
oldsn *data.Snapshot
hits int
printer interface {
- S(string, ...interface{})
- P(string, ...interface{})
- E(string, ...interface{})
+ S(string, ...any)
+ P(string, ...any)
+ E(string, ...any)
}
stdout io.Writer
}
@@ -281,9 +281,9 @@ type Finder struct {
treeIDs map[string]struct{}
itemsFound int
printer interface {
- S(string, ...interface{})
- P(string, ...interface{})
- E(string, ...interface{})
+ S(string, ...any)
+ P(string, ...any)
+ E(string, ...any)
}
}
diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go
index 93341ab65..cefe8d60d 100644
--- a/cmd/restic/cmd_ls.go
+++ b/cmd/restic/cmd_ls.go
@@ -290,8 +290,8 @@ type textLsPrinter struct {
ListLong bool
HumanReadable bool
termPrinter interface {
- P(msg string, args ...interface{})
- S(msg string, args ...interface{})
+ P(msg string, args ...any)
+ S(msg string, args ...any)
}
}
diff --git a/cmd/restic/cmd_ls_test.go b/cmd/restic/cmd_ls_test.go
index bbf92e6df..dc744883c 100644
--- a/cmd/restic/cmd_ls_test.go
+++ b/cmd/restic/cmd_ls_test.go
@@ -101,7 +101,7 @@ func TestLsNodeJSON(t *testing.T) {
rtest.Equals(t, expect+"\n", buf.String())
// Sanity check: output must be valid JSON.
- var v interface{}
+ var v any
err = json.NewDecoder(buf).Decode(&v)
rtest.OK(t, err)
}
@@ -121,7 +121,7 @@ func TestLsNcduNode(t *testing.T) {
rtest.Equals(t, expect, string(out))
// Sanity check: output must be valid JSON.
- var v interface{}
+ var v any
err = json.Unmarshal(out, &v)
rtest.OK(t, err)
}
diff --git a/cmd/restic/cmd_mount.go b/cmd/restic/cmd_mount.go
index 2c9decc7c..d47cbbb74 100644
--- a/cmd/restic/cmd_mount.go
+++ b/cmd/restic/cmd_mount.go
@@ -171,7 +171,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts global.Options, args
}
}
- systemFuse.Debug = func(msg interface{}) {
+ systemFuse.Debug = func(msg any) {
debug.Log("fuse: %v", msg)
}
diff --git a/helpers/build-release-binaries/main.go b/helpers/build-release-binaries/main.go
index d01bd93c1..0a1358c31 100644
--- a/helpers/build-release-binaries/main.go
+++ b/helpers/build-release-binaries/main.go
@@ -39,7 +39,7 @@ func init() {
pflag.Parse()
}
-func die(f string, args ...interface{}) {
+func die(f string, args ...any) {
if !strings.HasSuffix(f, "\n") {
f += "\n"
}
@@ -48,7 +48,7 @@ func die(f string, args ...interface{}) {
os.Exit(1)
}
-func msg(f string, args ...interface{}) {
+func msg(f string, args ...any) {
if !strings.HasSuffix(f, "\n") {
f += "\n"
}
@@ -56,7 +56,7 @@ func msg(f string, args ...interface{}) {
fmt.Printf(f, args...)
}
-func verbose(f string, args ...interface{}) {
+func verbose(f string, args ...any) {
if !opts.Verbose {
return
}
diff --git a/helpers/prepare-release/main.go b/helpers/prepare-release/main.go
index b0a636c29..7c864a88e 100644
--- a/helpers/prepare-release/main.go
+++ b/helpers/prepare-release/main.go
@@ -43,7 +43,7 @@ func init() {
pflag.Parse()
}
-func die(f string, args ...interface{}) {
+func die(f string, args ...any) {
if !strings.HasSuffix(f, "\n") {
f += "\n"
}
@@ -52,7 +52,7 @@ func die(f string, args ...interface{}) {
os.Exit(1)
}
-func msg(f string, args ...interface{}) {
+func msg(f string, args ...any) {
if !strings.HasSuffix(f, "\n") {
f += "\n"
}
diff --git a/internal/archiver/archiver_test.go b/internal/archiver/archiver_test.go
index 6c238263e..e3f5474ec 100644
--- a/internal/archiver/archiver_test.go
+++ b/internal/archiver/archiver_test.go
@@ -1982,7 +1982,7 @@ func TestArchiverParent(t *testing.T) {
t.Logf("testfs: %v", testFS)
// check that all files have been read exactly once
- TestWalkFiles(t, ".", test.src, func(filename string, item interface{}) error {
+ TestWalkFiles(t, ".", test.src, func(filename string, item any) error {
file, ok := item.(TestFile)
if !ok {
return nil
diff --git a/internal/archiver/exclude.go b/internal/archiver/exclude.go
index a7e11d781..571680929 100644
--- a/internal/archiver/exclude.go
+++ b/internal/archiver/exclude.go
@@ -88,7 +88,7 @@ func (rc *rejectionCache) Store(dir string, rejected bool) {
// non-nil if the filename component of excludeFileSpec is empty. If rc is
// non-nil, it is going to be used in the RejectByNameFunc to expedite the evaluation
// of a directory based on previous visits.
-func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...interface{})) (RejectFunc, error) {
+func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...any)) (RejectFunc, error) {
if excludeFileSpec == "" {
return nil, errors.New("name for exclusion tagfile is empty")
}
@@ -115,7 +115,7 @@ func RejectIfPresent(excludeFileSpec string, warnf func(msg string, args ...inte
// tagfile which bears the name specified in tagFilename and starts with
// header. If rc is non-nil, it is used to expedite the evaluation of a
// directory based on previous visits.
-func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache, fs fs.FS, warnf func(msg string, args ...interface{})) bool {
+func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache, fs fs.FS, warnf func(msg string, args ...any)) bool {
if tagFilename == "" {
return false
}
@@ -136,7 +136,7 @@ func isExcludedByFile(filename, tagFilename, header string, rc *rejectionCache,
return rejected
}
-func isDirExcludedByFile(dir, tagFilename, header string, fsInst fs.FS, warnf func(msg string, args ...interface{})) bool {
+func isDirExcludedByFile(dir, tagFilename, header string, fsInst fs.FS, warnf func(msg string, args ...any)) bool {
tf := fsInst.Join(dir, tagFilename)
_, err := fsInst.Lstat(tf)
if errors.Is(err, os.ErrNotExist) {
@@ -318,7 +318,7 @@ func RejectBySize(maxSize int64) (RejectFunc, error) {
}
// RejectCloudFiles returns a func which rejects files which are online-only cloud files
-func RejectCloudFiles(warnf func(msg string, args ...interface{})) (RejectFunc, error) {
+func RejectCloudFiles(warnf func(msg string, args ...any)) (RejectFunc, error) {
return func(item string, fi *fs.ExtendedFileInfo, _ fs.FS) bool {
recall, err := fi.RecallOnDataAccess()
if err != nil {
diff --git a/internal/archiver/exclude_test.go b/internal/archiver/exclude_test.go
index 4080f25f0..475ef2f69 100644
--- a/internal/archiver/exclude_test.go
+++ b/internal/archiver/exclude_test.go
@@ -49,7 +49,7 @@ func TestIsExcludedByFile(t *testing.T) {
if tc.content == "" {
h = ""
}
- if got := isExcludedByFile(foo, tagFilename, h, newRejectionCache(), fs.NewLocal(), func(msg string, args ...interface{}) { t.Logf(msg, args...) }); tc.want != got {
+ if got := isExcludedByFile(foo, tagFilename, h, newRejectionCache(), fs.NewLocal(), func(msg string, args ...any) { t.Logf(msg, args...) }); tc.want != got {
t.Fatalf("expected %v, got %v", tc.want, got)
}
})
diff --git a/internal/archiver/testing.go b/internal/archiver/testing.go
index bec70959f..abca347f4 100644
--- a/internal/archiver/testing.go
+++ b/internal/archiver/testing.go
@@ -41,7 +41,7 @@ func TestSnapshot(t testing.TB, repo restic.Repository, path string, parent *res
}
// TestDir describes a directory structure to create for a test.
-type TestDir map[string]interface{}
+type TestDir map[string]any
func (d TestDir) String() string {
return "
"
@@ -119,7 +119,7 @@ func TestCreateFiles(t testing.TB, target string, dir TestDir) {
// TestWalkFunc is used by TestWalkFiles to traverse the dir. When an error is
// returned, traversal stops and the surrounding test is marked as failed.
-type TestWalkFunc func(path string, item interface{}) error
+type TestWalkFunc func(path string, item any) error
// TestWalkFiles runs fn for each file/directory in dir, the filename will be
// constructed with target as the prefix. Symlinks on Windows are ignored.
@@ -158,7 +158,7 @@ func TestEnsureFiles(t testing.TB, target string, dir TestDir) {
pathsChecked := make(map[string]struct{})
// first, test that all items are there
- TestWalkFiles(t, target, dir, func(path string, item interface{}) error {
+ TestWalkFiles(t, target, dir, func(path string, item any) error {
fi, err := os.Lstat(path)
if err != nil {
return err
diff --git a/internal/archiver/testing_test.go b/internal/archiver/testing_test.go
index 6c395b94e..0805bd5b2 100644
--- a/internal/archiver/testing_test.go
+++ b/internal/archiver/testing_test.go
@@ -28,30 +28,30 @@ func (t *MockT) Fail() {
}
// Fatal is equivalent to Log followed by FailNow.
-func (t *MockT) Fatal(args ...interface{}) {
+func (t *MockT) Fatal(args ...any) {
t.T.Logf("MockT Fatal called with %v", args)
t.HasFailed = true
}
// Fatalf is equivalent to Logf followed by FailNow.
-func (t *MockT) Fatalf(msg string, args ...interface{}) {
+func (t *MockT) Fatalf(msg string, args ...any) {
t.T.Logf("MockT Fatal called: "+msg, args...)
t.HasFailed = true
}
// Error is equivalent to Log followed by Fail.
-func (t *MockT) Error(args ...interface{}) {
+func (t *MockT) Error(args ...any) {
t.T.Logf("MockT Error called with %v", args)
t.HasFailed = true
}
// Errorf is equivalent to Logf followed by Fail.
-func (t *MockT) Errorf(msg string, args ...interface{}) {
+func (t *MockT) Errorf(msg string, args ...any) {
t.T.Logf("MockT Error called: "+msg, args...)
t.HasFailed = true
}
-func createFilesAt(t testing.TB, targetdir string, files map[string]interface{}) {
+func createFilesAt(t testing.TB, targetdir string, files map[string]any) {
for name, item := range files {
target := filepath.Join(targetdir, filepath.FromSlash(name))
err := os.MkdirAll(filepath.Dir(target), 0700)
@@ -77,7 +77,7 @@ func createFilesAt(t testing.TB, targetdir string, files map[string]interface{})
func TestTestCreateFiles(t *testing.T) {
var tests = []struct {
dir TestDir
- files map[string]interface{}
+ files map[string]any
}{
{
dir: TestDir{
@@ -91,7 +91,7 @@ func TestTestCreateFiles(t *testing.T) {
},
},
},
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
"subdir": TestDir{},
"subdir/subfile": TestFile{Content: "bar"},
@@ -196,7 +196,7 @@ func TestTestWalkFiles(t *testing.T) {
got := make(map[string]string)
TestCreateFiles(t, tempdir, test.dir)
- TestWalkFiles(t, tempdir, test.dir, func(path string, item interface{}) error {
+ TestWalkFiles(t, tempdir, test.dir, func(path string, item any) error {
p, err := filepath.Rel(tempdir, path)
if err != nil {
return err
@@ -216,11 +216,11 @@ func TestTestWalkFiles(t *testing.T) {
func TestTestEnsureFiles(t *testing.T) {
var tests = []struct {
expectFailure bool
- files map[string]interface{}
+ files map[string]any
want TestDir
}{
{
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
"subdir/subfile": TestFile{Content: "bar"},
"x/y/link": TestSymlink{Target: filepath.Clean("../../foo")},
@@ -239,7 +239,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -251,7 +251,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
"subdir/subfile": TestFile{Content: "bar"},
},
@@ -261,7 +261,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "xxx"},
},
want: TestDir{
@@ -270,7 +270,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestSymlink{Target: "/xxx"},
},
want: TestDir{
@@ -279,7 +279,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -288,7 +288,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestSymlink{Target: "xxx"},
},
want: TestDir{
@@ -297,7 +297,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestDir{
"foo": TestFile{Content: "foo"},
},
@@ -308,7 +308,7 @@ func TestTestEnsureFiles(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -341,11 +341,11 @@ func TestTestEnsureFiles(t *testing.T) {
func TestTestEnsureSnapshot(t *testing.T) {
var tests = []struct {
expectFailure bool
- files map[string]interface{}
+ files map[string]any
want TestDir
}{
{
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
filepath.FromSlash("subdir/subfile"): TestFile{Content: "bar"},
filepath.FromSlash("x/y/link"): TestSymlink{Target: filepath.FromSlash("../../foo")},
@@ -366,7 +366,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -377,7 +377,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
"bar": TestFile{Content: "bar"},
},
@@ -389,7 +389,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -401,7 +401,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
@@ -414,7 +414,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestSymlink{Target: filepath.FromSlash("x/y/z")},
},
want: TestDir{
@@ -425,7 +425,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestSymlink{Target: filepath.FromSlash("x/y/z")},
},
want: TestDir{
@@ -436,7 +436,7 @@ func TestTestEnsureSnapshot(t *testing.T) {
},
{
expectFailure: true,
- files: map[string]interface{}{
+ files: map[string]any{
"foo": TestFile{Content: "foo"},
},
want: TestDir{
diff --git a/internal/backend/azure/azure.go b/internal/backend/azure/azure.go
index 234e5ddd1..8e88af896 100644
--- a/internal/backend/azure/azure.go
+++ b/internal/backend/azure/azure.go
@@ -158,13 +158,13 @@ func supportedAccessTiers() []blob.AccessTier {
}
// Open opens the Azure backend at specified container.
-func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (*Backend, error) {
+func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (*Backend, error) {
return open(cfg, rt)
}
// Create opens the Azure backend at specified container and creates the container if
// it does not exist yet.
-func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (*Backend, error) {
+func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (*Backend, error) {
be, err := open(cfg, rt)
if err != nil {
diff --git a/internal/backend/b2/b2.go b/internal/backend/b2/b2.go
index 567a2875c..e23455d13 100644
--- a/internal/backend/b2/b2.go
+++ b/internal/backend/b2/b2.go
@@ -87,7 +87,7 @@ func newClient(ctx context.Context, cfg Config, rt http.RoundTripper) (*b2.Clien
}
// Open opens a connection to the B2 service.
-func Open(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Open(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
debug.Log("cfg %#v", cfg)
ctx, cancel := context.WithCancel(ctx)
@@ -118,7 +118,7 @@ func Open(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string,
// Create opens a connection to the B2 service. If the bucket does not exist yet,
// it is created.
-func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
debug.Log("cfg %#v", cfg)
ctx, cancel := context.WithCancel(ctx)
diff --git a/internal/backend/cache/backend.go b/internal/backend/cache/backend.go
index db47767a0..e5dacc692 100644
--- a/internal/backend/cache/backend.go
+++ b/internal/backend/cache/backend.go
@@ -19,13 +19,13 @@ type cacheBackend struct {
// is finished.
inProgressMutex sync.Mutex
inProgress map[backend.Handle]chan struct{}
- errorLog func(string, ...interface{})
+ errorLog func(string, ...any)
}
// ensure Backend implements backend.Backend
var _ backend.Backend = &cacheBackend{}
-func newBackend(be backend.Backend, c *Cache, errorLog func(string, ...interface{})) *cacheBackend {
+func newBackend(be backend.Backend, c *Cache, errorLog func(string, ...any)) *cacheBackend {
return &cacheBackend{
Backend: be,
Cache: c,
diff --git a/internal/backend/cache/cache.go b/internal/backend/cache/cache.go
index 22c3532ce..2244999ef 100644
--- a/internal/backend/cache/cache.go
+++ b/internal/backend/cache/cache.go
@@ -236,7 +236,7 @@ func IsOld(t time.Time, maxAge time.Duration) bool {
}
// Wrap returns a backend with a cache.
-func (c *Cache) Wrap(be backend.Backend, errorLog func(string, ...interface{})) backend.Backend {
+func (c *Cache) Wrap(be backend.Backend, errorLog func(string, ...any)) backend.Backend {
return newBackend(be, c, errorLog)
}
diff --git a/internal/backend/gs/gs.go b/internal/backend/gs/gs.go
index 8ebc4902c..5e8a45e81 100644
--- a/internal/backend/gs/gs.go
+++ b/internal/backend/gs/gs.go
@@ -114,7 +114,7 @@ func open(cfg Config, rt http.RoundTripper) (*gs, error) {
}
// Open opens the gs backend at the specified bucket.
-func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
return open(cfg, rt)
}
@@ -123,7 +123,7 @@ func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ..
//
// The service account must have the "storage.buckets.create" permission to
// create a bucket the does not yet exist.
-func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
be, err := open(cfg, rt)
if err != nil {
return nil, err
diff --git a/internal/backend/limiter/limiter_backend.go b/internal/backend/limiter/limiter_backend.go
index 945777688..6f4f2a03a 100644
--- a/internal/backend/limiter/limiter_backend.go
+++ b/internal/backend/limiter/limiter_backend.go
@@ -7,8 +7,8 @@ import (
"github.com/restic/restic/internal/backend"
)
-func WrapBackendConstructor[B backend.Backend, C any](constructor func(ctx context.Context, cfg C, errorLog func(string, ...interface{})) (B, error)) func(ctx context.Context, cfg C, lim Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
- return func(ctx context.Context, cfg C, lim Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
+func WrapBackendConstructor[B backend.Backend, C any](constructor func(ctx context.Context, cfg C, errorLog func(string, ...any)) (B, error)) func(ctx context.Context, cfg C, lim Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
+ return func(ctx context.Context, cfg C, lim Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
var be backend.Backend
be, err := constructor(ctx, cfg, errorLog)
if err != nil {
diff --git a/internal/backend/local/local.go b/internal/backend/local/local.go
index 3a1237ee8..141769913 100644
--- a/internal/backend/local/local.go
+++ b/internal/backend/local/local.go
@@ -52,14 +52,14 @@ func open(cfg Config) (*Local, error) {
}
// Open opens the local backend as specified by config.
-func Open(_ context.Context, cfg Config, _ func(string, ...interface{})) (*Local, error) {
+func Open(_ context.Context, cfg Config, _ func(string, ...any)) (*Local, error) {
debug.Log("open local backend at %v", cfg.Path)
return open(cfg)
}
// Create creates all the necessary files and directories for a new local
// backend at dir. Afterwards a new config blob should be created.
-func Create(_ context.Context, cfg Config, _ func(string, ...interface{})) (*Local, error) {
+func Create(_ context.Context, cfg Config, _ func(string, ...any)) (*Local, error) {
debug.Log("create local backend at %v", cfg.Path)
be, err := open(cfg)
diff --git a/internal/backend/location/location.go b/internal/backend/location/location.go
index db82d1825..4175b87b7 100644
--- a/internal/backend/location/location.go
+++ b/internal/backend/location/location.go
@@ -11,7 +11,7 @@ import (
// access and (possibly) credentials needed for access.
type Location struct {
Scheme string
- Config interface{}
+ Config any
}
// NoPassword returns the repository location unchanged (there's no sensitive information there)
diff --git a/internal/backend/location/registry.go b/internal/backend/location/registry.go
index c0761e76b..be8d282e8 100644
--- a/internal/backend/location/registry.go
+++ b/internal/backend/location/registry.go
@@ -31,25 +31,25 @@ func (r *Registry) Lookup(scheme string) Factory {
type Factory interface {
Scheme() string
- ParseConfig(s string) (interface{}, error)
+ ParseConfig(s string) (any, error)
StripPassword(s string) string
- Create(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error)
- Open(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error)
+ Create(ctx context.Context, cfg any, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error)
+ Open(ctx context.Context, cfg any, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error)
}
type genericBackendFactory[C any, T backend.Backend] struct {
scheme string
parseConfigFn func(s string) (*C, error)
stripPasswordFn func(s string) string
- createFn func(ctx context.Context, cfg C, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error)
- openFn func(ctx context.Context, cfg C, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error)
+ createFn func(ctx context.Context, cfg C, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (T, error)
+ openFn func(ctx context.Context, cfg C, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (T, error)
}
func (f *genericBackendFactory[C, T]) Scheme() string {
return f.scheme
}
-func (f *genericBackendFactory[C, T]) ParseConfig(s string) (interface{}, error) {
+func (f *genericBackendFactory[C, T]) ParseConfig(s string) (any, error) {
return f.parseConfigFn(s)
}
func (f *genericBackendFactory[C, T]) StripPassword(s string) string {
@@ -58,10 +58,10 @@ func (f *genericBackendFactory[C, T]) StripPassword(s string) string {
}
return s
}
-func (f *genericBackendFactory[C, T]) Create(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
+func (f *genericBackendFactory[C, T]) Create(ctx context.Context, cfg any, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
return f.createFn(ctx, *cfg.(*C), rt, lim, errorLog)
}
-func (f *genericBackendFactory[C, T]) Open(ctx context.Context, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
+func (f *genericBackendFactory[C, T]) Open(ctx context.Context, cfg any, rt http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
return f.openFn(ctx, *cfg.(*C), rt, lim, errorLog)
}
@@ -69,17 +69,17 @@ func NewHTTPBackendFactory[C any, T backend.Backend](
scheme string,
parseConfigFn func(s string) (*C, error),
stripPasswordFn func(s string) string,
- createFn func(ctx context.Context, cfg C, rt http.RoundTripper, errorLog func(string, ...interface{})) (T, error),
- openFn func(ctx context.Context, cfg C, rt http.RoundTripper, errorLog func(string, ...interface{})) (T, error)) Factory {
+ createFn func(ctx context.Context, cfg C, rt http.RoundTripper, errorLog func(string, ...any)) (T, error),
+ openFn func(ctx context.Context, cfg C, rt http.RoundTripper, errorLog func(string, ...any)) (T, error)) Factory {
return &genericBackendFactory[C, T]{
scheme: scheme,
parseConfigFn: parseConfigFn,
stripPasswordFn: stripPasswordFn,
- createFn: func(ctx context.Context, cfg C, rt http.RoundTripper, _ limiter.Limiter, errorLog func(string, ...interface{})) (T, error) {
+ createFn: func(ctx context.Context, cfg C, rt http.RoundTripper, _ limiter.Limiter, errorLog func(string, ...any)) (T, error) {
return createFn(ctx, cfg, rt, errorLog)
},
- openFn: func(ctx context.Context, cfg C, rt http.RoundTripper, _ limiter.Limiter, errorLog func(string, ...interface{})) (T, error) {
+ openFn: func(ctx context.Context, cfg C, rt http.RoundTripper, _ limiter.Limiter, errorLog func(string, ...any)) (T, error) {
return openFn(ctx, cfg, rt, errorLog)
},
}
@@ -89,17 +89,17 @@ func NewLimitedBackendFactory[C any, T backend.Backend](
scheme string,
parseConfigFn func(s string) (*C, error),
stripPasswordFn func(s string) string,
- createFn func(ctx context.Context, cfg C, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error),
- openFn func(ctx context.Context, cfg C, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error)) Factory {
+ createFn func(ctx context.Context, cfg C, lim limiter.Limiter, errorLog func(string, ...any)) (T, error),
+ openFn func(ctx context.Context, cfg C, lim limiter.Limiter, errorLog func(string, ...any)) (T, error)) Factory {
return &genericBackendFactory[C, T]{
scheme: scheme,
parseConfigFn: parseConfigFn,
stripPasswordFn: stripPasswordFn,
- createFn: func(ctx context.Context, cfg C, _ http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error) {
+ createFn: func(ctx context.Context, cfg C, _ http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (T, error) {
return createFn(ctx, cfg, lim, errorLog)
},
- openFn: func(ctx context.Context, cfg C, _ http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...interface{})) (T, error) {
+ openFn: func(ctx context.Context, cfg C, _ http.RoundTripper, lim limiter.Limiter, errorLog func(string, ...any)) (T, error) {
return openFn(ctx, cfg, lim, errorLog)
},
}
diff --git a/internal/backend/mem/mem_backend.go b/internal/backend/mem/mem_backend.go
index 6ff38867c..b97996b0c 100644
--- a/internal/backend/mem/mem_backend.go
+++ b/internal/backend/mem/mem_backend.go
@@ -33,10 +33,10 @@ func NewFactory() location.Factory {
return &struct{}{}, nil
},
location.NoPassword,
- func(_ context.Context, _ struct{}, _ http.RoundTripper, _ func(string, ...interface{})) (*MemoryBackend, error) {
+ func(_ context.Context, _ struct{}, _ http.RoundTripper, _ func(string, ...any)) (*MemoryBackend, error) {
return be, nil
},
- func(_ context.Context, _ struct{}, _ http.RoundTripper, _ func(string, ...interface{})) (*MemoryBackend, error) {
+ func(_ context.Context, _ struct{}, _ http.RoundTripper, _ func(string, ...any)) (*MemoryBackend, error) {
return be, nil
},
)
diff --git a/internal/backend/rclone/backend.go b/internal/backend/rclone/backend.go
index 19d956b3f..a5944062d 100644
--- a/internal/backend/rclone/backend.go
+++ b/internal/backend/rclone/backend.go
@@ -44,7 +44,7 @@ func NewFactory() location.Factory {
}
// run starts command with args and initializes the StdioConn.
-func run(errorLog func(string, ...interface{}), command string, args ...string) (*StdioConn, *sync.WaitGroup, chan struct{}, func() error, error) {
+func run(errorLog func(string, ...any), command string, args ...string) (*StdioConn, *sync.WaitGroup, chan struct{}, func() error, error) {
cmd := exec.Command(command, args...)
p, err := cmd.StderrPipe()
@@ -141,7 +141,7 @@ func wrapConn(c *StdioConn, lim limiter.Limiter) *wrappedConn {
}
// New initializes a Backend and starts the process.
-func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...interface{})) (*rclone, error) {
+func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...any)) (*rclone, error) {
var (
args []string
err error
@@ -270,7 +270,7 @@ func newBackend(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog f
}
// Open starts an rclone process with the given config.
-func Open(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
+func Open(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
be, err := newBackend(ctx, cfg, lim, errorLog)
if err != nil {
return nil, err
@@ -297,7 +297,7 @@ func Open(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(st
}
// Create initializes a new restic repo with rclone.
-func Create(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...interface{})) (backend.Backend, error) {
+func Create(ctx context.Context, cfg Config, lim limiter.Limiter, errorLog func(string, ...any)) (backend.Backend, error) {
be, err := newBackend(ctx, cfg, lim, errorLog)
if err != nil {
return nil, err
diff --git a/internal/backend/rest/rest.go b/internal/backend/rest/rest.go
index c3ed1801f..25483c90c 100644
--- a/internal/backend/rest/rest.go
+++ b/internal/backend/rest/rest.go
@@ -55,7 +55,7 @@ const (
)
// Open opens the REST backend with the given config.
-func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (*Backend, error) {
+func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (*Backend, error) {
// use url without trailing slash for layout
url := cfg.URL.String()
if url[len(url)-1] == '/' {
@@ -84,7 +84,7 @@ func drainAndClose(resp *http.Response) error {
}
// Create creates a new REST on server configured in config.
-func Create(ctx context.Context, cfg Config, rt http.RoundTripper, errorLog func(string, ...interface{})) (*Backend, error) {
+func Create(ctx context.Context, cfg Config, rt http.RoundTripper, errorLog func(string, ...any)) (*Backend, error) {
be, err := Open(ctx, cfg, rt, errorLog)
if err != nil {
return nil, err
diff --git a/internal/backend/s3/s3.go b/internal/backend/s3/s3.go
index 2b249e705..177503395 100644
--- a/internal/backend/s3/s3.go
+++ b/internal/backend/s3/s3.go
@@ -197,13 +197,13 @@ func getCredentials(cfg Config, tr http.RoundTripper) (*credentials.Credentials,
// Open opens the S3 backend at bucket and region. The bucket is created if it
// does not exist yet.
-func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Open(_ context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
return open(cfg, rt)
}
// Create opens the S3 backend at bucket and region and creates the bucket if
// it does not exist yet.
-func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Create(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
be, err := open(cfg, rt)
if err != nil {
return nil, errors.Wrap(err, "open")
diff --git a/internal/backend/s3/s3_test.go b/internal/backend/s3/s3_test.go
index b026ce427..8935a88f8 100644
--- a/internal/backend/s3/s3_test.go
+++ b/internal/backend/s3/s3_test.go
@@ -117,7 +117,7 @@ func newMinioTestSuite(t testing.TB) (*test.Suite[s3.Config], func()) {
return &cfg, nil
},
- Factory: location.NewHTTPBackendFactory("s3", s3.ParseConfig, location.NoPassword, func(ctx context.Context, cfg s3.Config, rt http.RoundTripper, errorLog func(string, ...interface{})) (be backend.Backend, err error) {
+ Factory: location.NewHTTPBackendFactory("s3", s3.ParseConfig, location.NoPassword, func(ctx context.Context, cfg s3.Config, rt http.RoundTripper, errorLog func(string, ...any)) (be backend.Backend, err error) {
for i := 0; i < 50; i++ {
be, err = s3.Create(ctx, cfg, rt, errorLog)
if err != nil {
diff --git a/internal/backend/sftp/sftp.go b/internal/backend/sftp/sftp.go
index dcc2ea5a7..f33f2b42d 100644
--- a/internal/backend/sftp/sftp.go
+++ b/internal/backend/sftp/sftp.go
@@ -54,7 +54,7 @@ func NewFactory() location.Factory {
return location.NewLimitedBackendFactory("sftp", ParseConfig, location.NoPassword, limiter.WrapBackendConstructor(Create), limiter.WrapBackendConstructor(Open))
}
-func startClient(cfg Config, errorLog func(string, ...interface{})) (*SFTP, error) {
+func startClient(cfg Config, errorLog func(string, ...any)) (*SFTP, error) {
program, args, err := buildSSHCommand(cfg)
if err != nil {
return nil, err
@@ -147,7 +147,7 @@ func (r *SFTP) clientError() error {
// Open opens an sftp backend as described by the config by running
// "ssh" with the appropriate arguments (or cfg.Command, if set).
-func Open(_ context.Context, cfg Config, errorLog func(string, ...interface{})) (*SFTP, error) {
+func Open(_ context.Context, cfg Config, errorLog func(string, ...any)) (*SFTP, error) {
debug.Log("open backend with config %#v", cfg)
sftp, err := startClient(cfg, errorLog)
@@ -273,7 +273,7 @@ func buildSSHCommand(cfg Config) (cmd string, args []string, err error) {
// Create creates an sftp backend as described by the config by running "ssh"
// with the appropriate arguments (or cfg.Command, if set).
-func Create(ctx context.Context, cfg Config, errorLog func(string, ...interface{})) (*SFTP, error) {
+func Create(ctx context.Context, cfg Config, errorLog func(string, ...any)) (*SFTP, error) {
sftp, err := startClient(cfg, errorLog)
if err != nil {
debug.Log("unable to start program: %v", err)
diff --git a/internal/backend/sftp/sftp_test.go b/internal/backend/sftp/sftp_test.go
index f9ce09608..1d4fde095 100644
--- a/internal/backend/sftp/sftp_test.go
+++ b/internal/backend/sftp/sftp_test.go
@@ -82,7 +82,7 @@ func TestCreateSetsDirPermissions(t *testing.T) {
cfg := testConfig(filepath.Join(rtest.TempDir(t), "repo"))
- be, err := sftp.Create(context.Background(), cfg, func(string, ...interface{}) {})
+ be, err := sftp.Create(context.Background(), cfg, func(string, ...any) {})
rtest.OK(t, err)
defer func() { rtest.OK(t, be.Close()) }()
@@ -108,7 +108,7 @@ func TestSaveSetsDirPermissions(t *testing.T) {
cfg := testConfig(filepath.Join(rtest.TempDir(t), "repo"))
- be, err := sftp.Create(context.Background(), cfg, func(string, ...interface{}) {})
+ be, err := sftp.Create(context.Background(), cfg, func(string, ...any) {})
rtest.OK(t, err)
defer func() { rtest.OK(t, be.Close()) }()
diff --git a/internal/backend/swift/swift.go b/internal/backend/swift/swift.go
index 155b5041e..4256c5442 100644
--- a/internal/backend/swift/swift.go
+++ b/internal/backend/swift/swift.go
@@ -42,7 +42,7 @@ func NewFactory() location.Factory {
// Open opens the swift backend at a container in region. The container is
// created if it does not exist yet.
-func Open(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...interface{})) (backend.Backend, error) {
+func Open(ctx context.Context, cfg Config, rt http.RoundTripper, _ func(string, ...any)) (backend.Backend, error) {
debug.Log("config %#v", cfg)
be := &beSwift{
@@ -202,7 +202,7 @@ func (be *beSwift) List(ctx context.Context, t backend.FileType, fn func(backend
prefix += "/"
err := be.conn.ObjectsWalk(ctx, be.container, &swift.ObjectsOpts{Prefix: prefix},
- func(ctx context.Context, opts *swift.ObjectsOpts) (interface{}, error) {
+ func(ctx context.Context, opts *swift.ObjectsOpts) (any, error) {
newObjects, err := be.conn.Objects(ctx, be.container, opts)
if err != nil {
diff --git a/internal/backend/test/suite.go b/internal/backend/test/suite.go
index 86acc5cb5..704b08fc5 100644
--- a/internal/backend/test/suite.go
+++ b/internal/backend/test/suite.go
@@ -192,7 +192,7 @@ func (s *Suite[C]) open(t testing.TB) backend.Backend {
t.Fatalf("cannot create transport for tests: %v", err)
}
- be, err := s.Factory.Open(context.TODO(), s.Config, tr, nil, func(string, ...interface{}) {})
+ be, err := s.Factory.Open(context.TODO(), s.Config, tr, nil, func(string, ...any) {})
if err != nil {
t.Fatal(err)
}
diff --git a/internal/debug/debug.go b/internal/debug/debug.go
index a8c3a7f33..0bcfbc81b 100644
--- a/internal/debug/debug.go
+++ b/internal/debug/debug.go
@@ -161,7 +161,7 @@ func checkFilter(filter map[string]bool, key string) bool {
}
// Log prints a message to the debug log (if debug is enabled).
-func Log(f string, args ...interface{}) {
+func Log(f string, args ...any) {
if !opts.isEnabled {
return
}
diff --git a/internal/errors/errors.go b/internal/errors/errors.go
index 96e5b82bb..7a0ad1c18 100644
--- a/internal/errors/errors.go
+++ b/internal/errors/errors.go
@@ -30,7 +30,7 @@ var WithStack = errors.WithStack
// As finds the first error in err's tree that matches target, and if one is found,
// sets target to that error value and returns true. Otherwise, it returns false.
-func As(err error, tgt interface{}) bool { return stderrors.As(err, tgt) }
+func As(err error, tgt any) bool { return stderrors.As(err, tgt) }
// Is reports whether any error in err's tree matches target.
func Is(x, y error) bool { return stderrors.Is(x, y) }
diff --git a/internal/errors/fatal.go b/internal/errors/fatal.go
index 12b310aca..f7029df0e 100644
--- a/internal/errors/fatal.go
+++ b/internal/errors/fatal.go
@@ -33,7 +33,7 @@ func Fatal(s string) error {
}
// Fatalf returns an error that is marked fatal, preserving an underlying error if passed.
-func Fatalf(s string, data ...interface{}) error {
+func Fatalf(s string, data ...any) error {
// Use the last error found.
var underlyingErr error
for i := len(data) - 1; i >= 0; i-- {
diff --git a/internal/filter/exclude.go b/internal/filter/exclude.go
index 1d3042a58..44f4331c0 100644
--- a/internal/filter/exclude.go
+++ b/internal/filter/exclude.go
@@ -20,7 +20,7 @@ type RejectByNameFunc func(path string) bool
// RejectByPattern returns a RejectByNameFunc which rejects files that match
// one of the patterns.
-func RejectByPattern(patterns []string, warnf func(msg string, args ...interface{})) RejectByNameFunc {
+func RejectByPattern(patterns []string, warnf func(msg string, args ...any)) RejectByNameFunc {
parsedPatterns := ParsePatterns(patterns)
return func(item string) bool {
matched, err := List(parsedPatterns, item)
@@ -38,7 +38,7 @@ func RejectByPattern(patterns []string, warnf func(msg string, args ...interface
}
// RejectByInsensitivePattern is like RejectByPattern but case insensitive.
-func RejectByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) RejectByNameFunc {
+func RejectByInsensitivePattern(patterns []string, warnf func(msg string, args ...any)) RejectByNameFunc {
lowerPatterns := make([]string, len(patterns))
for index, path := range patterns {
lowerPatterns[index] = strings.ToLower(path)
@@ -115,7 +115,7 @@ func (opts *ExcludePatternOptions) Empty() bool {
return len(opts.Excludes) == 0 && len(opts.InsensitiveExcludes) == 0 && len(opts.ExcludeFiles) == 0 && len(opts.InsensitiveExcludeFiles) == 0
}
-func (opts ExcludePatternOptions) CollectPatterns(warnf func(msg string, args ...interface{})) ([]RejectByNameFunc, error) {
+func (opts ExcludePatternOptions) CollectPatterns(warnf func(msg string, args ...any)) ([]RejectByNameFunc, error) {
var fs []RejectByNameFunc
// add patterns from file
if len(opts.ExcludeFiles) > 0 {
diff --git a/internal/filter/include.go b/internal/filter/include.go
index 56c4d7258..ae512b521 100644
--- a/internal/filter/include.go
+++ b/internal/filter/include.go
@@ -29,7 +29,7 @@ func (opts *IncludePatternOptions) Empty() bool {
return len(opts.Includes) == 0 && len(opts.InsensitiveIncludes) == 0 && len(opts.IncludeFiles) == 0 && len(opts.InsensitiveIncludeFiles) == 0
}
-func (opts IncludePatternOptions) CollectPatterns(warnf func(msg string, args ...interface{})) ([]IncludeByNameFunc, error) {
+func (opts IncludePatternOptions) CollectPatterns(warnf func(msg string, args ...any)) ([]IncludeByNameFunc, error) {
var fs []IncludeByNameFunc
if len(opts.IncludeFiles) > 0 {
includePatterns, err := readPatternsFromFiles(opts.IncludeFiles)
@@ -77,7 +77,7 @@ func (opts IncludePatternOptions) CollectPatterns(warnf func(msg string, args ..
// IncludeByPattern returns an IncludeByNameFunc which includes files that match
// one of the patterns.
-func IncludeByPattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc {
+func IncludeByPattern(patterns []string, warnf func(msg string, args ...any)) IncludeByNameFunc {
parsedPatterns := ParsePatterns(patterns)
return func(item string) (matched bool, childMayMatch bool) {
matched, childMayMatch, err := ListWithChild(parsedPatterns, item)
@@ -91,7 +91,7 @@ func IncludeByPattern(patterns []string, warnf func(msg string, args ...interfac
// IncludeByInsensitivePattern returns an IncludeByNameFunc which includes files that match
// one of the patterns, ignoring the casing of the filenames.
-func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...interface{})) IncludeByNameFunc {
+func IncludeByInsensitivePattern(patterns []string, warnf func(msg string, args ...any)) IncludeByNameFunc {
lowerPatterns := make([]string, len(patterns))
for index, path := range patterns {
lowerPatterns[index] = strings.ToLower(path)
diff --git a/internal/fs/fs_local_vss.go b/internal/fs/fs_local_vss.go
index 1dc5b771c..cc4074f79 100644
--- a/internal/fs/fs_local_vss.go
+++ b/internal/fs/fs_local_vss.go
@@ -42,7 +42,7 @@ func ParseVSSConfig(o options.Options) (VSSConfig, error) {
type ErrorHandler func(item string, err error)
// MessageHandler is used to report errors/messages via callbacks.
-type MessageHandler func(msg string, args ...interface{})
+type MessageHandler func(msg string, args ...any)
// volumeFilter is used to filter volumes by their mount point or GUID path.
type volumeFilter func(volume string) bool
diff --git a/internal/fs/fs_reader_command.go b/internal/fs/fs_reader_command.go
index c2d359d92..16313bf1b 100644
--- a/internal/fs/fs_reader_command.go
+++ b/internal/fs/fs_reader_command.go
@@ -28,7 +28,7 @@ type commandReader struct {
alreadyClosedReadErr error
}
-func NewCommandReader(ctx context.Context, args []string, errorOutput func(msg string, args ...interface{})) (io.ReadCloser, error) {
+func NewCommandReader(ctx context.Context, args []string, errorOutput func(msg string, args ...any)) (io.ReadCloser, error) {
if len(args) == 0 {
return nil, fmt.Errorf("no command was specified as argument")
}
diff --git a/internal/fs/fs_reader_command_test.go b/internal/fs/fs_reader_command_test.go
index 214b1003e..dd8e1c0e0 100644
--- a/internal/fs/fs_reader_command_test.go
+++ b/internal/fs/fs_reader_command_test.go
@@ -13,7 +13,7 @@ import (
)
func TestCommandReaderSuccess(t *testing.T) {
- reader, err := fs.NewCommandReader(context.TODO(), []string{"true"}, func(msg string, args ...interface{}) {})
+ reader, err := fs.NewCommandReader(context.TODO(), []string{"true"}, func(msg string, args ...any) {})
test.OK(t, err)
_, err = io.Copy(io.Discard, reader)
@@ -23,7 +23,7 @@ func TestCommandReaderSuccess(t *testing.T) {
}
func TestCommandReaderFail(t *testing.T) {
- reader, err := fs.NewCommandReader(context.TODO(), []string{"false"}, func(msg string, args ...interface{}) {})
+ reader, err := fs.NewCommandReader(context.TODO(), []string{"false"}, func(msg string, args ...any) {})
test.OK(t, err)
_, err = io.Copy(io.Discard, reader)
@@ -31,17 +31,17 @@ func TestCommandReaderFail(t *testing.T) {
}
func TestCommandReaderInvalid(t *testing.T) {
- _, err := fs.NewCommandReader(context.TODO(), []string{"w54fy098hj7fy5twijouytfrj098y645wr"}, func(msg string, args ...interface{}) {})
+ _, err := fs.NewCommandReader(context.TODO(), []string{"w54fy098hj7fy5twijouytfrj098y645wr"}, func(msg string, args ...any) {})
test.Assert(t, err != nil, "missing error")
}
func TestCommandReaderEmptyArgs(t *testing.T) {
- _, err := fs.NewCommandReader(context.TODO(), []string{}, func(msg string, args ...interface{}) {})
+ _, err := fs.NewCommandReader(context.TODO(), []string{}, func(msg string, args ...any) {})
test.Assert(t, err != nil, "missing error")
}
func TestCommandReaderOutput(t *testing.T) {
- reader, err := fs.NewCommandReader(context.TODO(), []string{"echo", "hello world"}, func(msg string, args ...interface{}) {})
+ reader, err := fs.NewCommandReader(context.TODO(), []string{"echo", "hello world"}, func(msg string, args ...any) {})
test.OK(t, err)
var buf bytes.Buffer
@@ -56,7 +56,7 @@ func TestCommandReaderOutput(t *testing.T) {
func TestCommandReaderQuickClose(t *testing.T) {
ctx, cancel := context.WithTimeout(context.TODO(), 10*time.Second)
defer cancel()
- reader, err := fs.NewCommandReader(ctx, []string{"sleep", "3600"}, func(msg string, args ...interface{}) {})
+ reader, err := fs.NewCommandReader(ctx, []string{"sleep", "3600"}, func(msg string, args ...any) {})
test.OK(t, err)
// test that close returns before the context expires
diff --git a/internal/fs/node_xattr_all_test.go b/internal/fs/node_xattr_all_test.go
index 0a2a62c45..08621993e 100644
--- a/internal/fs/node_xattr_all_test.go
+++ b/internal/fs/node_xattr_all_test.go
@@ -122,7 +122,7 @@ func TestOverwriteXattrWithSelectFilter(t *testing.T) {
file := filepath.Join(dir, "file2")
rtest.OK(t, os.WriteFile(file, []byte("hello world"), 0o600))
- noopWarnf := func(_ string, _ ...interface{}) {}
+ noopWarnf := func(_ string, _ ...any) {}
// Set a filter as if the user passed in --include-xattr user.*
xattrSelectFilter1 := func(xattrName string) bool {
diff --git a/internal/global/global.go b/internal/global/global.go
index e44182de1..4df90a600 100644
--- a/internal/global/global.go
+++ b/internal/global/global.go
@@ -522,7 +522,7 @@ func innerOpenBackend(ctx context.Context, s string, gopts Options, opts options
}
// parseConfig parses the repository location and extended options and returns the scheme and configuration.
-func parseConfig(backends *location.Registry, s string, opts options.Options) (string, interface{}, error) {
+func parseConfig(backends *location.Registry, s string, opts options.Options) (string, any, error) {
loc, err := location.Parse(backends, s)
if err != nil {
return "", nil, errors.Fatalf("parsing repository location failed: %v", err)
@@ -558,7 +558,7 @@ func setupTransport(gopts Options) (http.RoundTripper, limiter.Limiter, error) {
}
// createOrOpenBackend creates or opens a backend using the appropriate factory method.
-func createOrOpenBackend(ctx context.Context, scheme string, cfg interface{}, rt http.RoundTripper, lim limiter.Limiter, gopts Options, s string, create bool, printer restic.Printer) (backend.Backend, error) {
+func createOrOpenBackend(ctx context.Context, scheme string, cfg any, rt http.RoundTripper, lim limiter.Limiter, gopts Options, s string, create bool, printer restic.Printer) (backend.Backend, error) {
factory := gopts.Backends.Lookup(scheme)
if factory == nil {
return nil, errors.Fatalf("invalid backend: %q", scheme)
diff --git a/internal/options/options.go b/internal/options/options.go
index 7490ac430..71236e940 100644
--- a/internal/options/options.go
+++ b/internal/options/options.go
@@ -16,7 +16,7 @@ type Options map[string]string
var opts []Help
// Register allows registering options so that they can be listed with List.
-func Register(ns string, cfg interface{}) {
+func Register(ns string, cfg any) {
opts = appendAllOptions(opts, ns, cfg)
}
@@ -28,7 +28,7 @@ func List() (list []Help) {
}
// appendAllOptions appends all options in cfg to opts, sorted by namespace.
-func appendAllOptions(opts []Help, ns string, cfg interface{}) []Help {
+func appendAllOptions(opts []Help, ns string, cfg any) []Help {
for _, opt := range listOptions(cfg) {
opt.Namespace = ns
opts = append(opts, opt)
@@ -39,7 +39,7 @@ func appendAllOptions(opts []Help, ns string, cfg interface{}) []Help {
}
// listOptions returns a list of options of cfg.
-func listOptions(cfg interface{}) (opts []Help) {
+func listOptions(cfg any) (opts []Help) {
// resolve indirection if cfg is a pointer
v := reflect.Indirect(reflect.ValueOf(cfg))
@@ -145,7 +145,7 @@ func (o Options) Extract(ns string) Options {
// Apply sets the options on dst via reflection, using the struct tag `option`.
// The namespace argument (ns) is only used for error messages.
-func (o Options) Apply(ns string, dst interface{}) error {
+func (o Options) Apply(ns string, dst any) error {
v := reflect.ValueOf(dst).Elem()
fields := make(map[string]reflect.StructField)
diff --git a/internal/options/options_test.go b/internal/options/options_test.go
index ce5153f5b..c83f87639 100644
--- a/internal/options/options_test.go
+++ b/internal/options/options_test.go
@@ -247,7 +247,7 @@ func TestListOptions(t *testing.T) {
}{}
tests := []struct {
- cfg interface{}
+ cfg any
opts []Help
}{
{
@@ -298,11 +298,11 @@ func TestListOptions(t *testing.T) {
func TestAppendAllOptions(t *testing.T) {
tests := []struct {
- cfgs map[string]interface{}
+ cfgs map[string]any
opts []Help
}{
{
- map[string]interface{}{
+ map[string]any{
"local": struct {
Foo string `option:"foo" help:"bar text help"`
}{},
diff --git a/internal/repository/lock.go b/internal/repository/lock.go
index 9a3e8aba5..2b0670c44 100644
--- a/internal/repository/lock.go
+++ b/internal/repository/lock.go
@@ -44,11 +44,11 @@ var lockerInst = &locker{
// LockRepo acquires a repository lock. The returned context is cancelled when
// Unlock is called; cancelling the original context stops lock refresh.
-func LockRepo(ctx context.Context, repo *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (func(), context.Context, error) {
+func LockRepo(ctx context.Context, repo *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...any)) (func(), context.Context, error) {
return lockerInst.Lock(ctx, repo, exclusive, retryLock, printRetry, logger)
}
-func (l *locker) Lock(ctx context.Context, r *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...interface{})) (func(), context.Context, error) {
+func (l *locker) Lock(ctx context.Context, r *Repository, exclusive bool, retryLock time.Duration, printRetry func(msg string), logger func(format string, args ...any)) (func(), context.Context, error) {
var lock *lockHandle
var err error
@@ -121,7 +121,7 @@ type refreshLockRequest struct {
result chan bool
}
-func (l *locker) refreshLocks(ctx context.Context, backend backend.Backend, unlocker *unlocker, refreshed chan<- struct{}, forceRefresh <-chan refreshLockRequest, logger func(format string, args ...interface{})) {
+func (l *locker) refreshLocks(ctx context.Context, backend backend.Backend, unlocker *unlocker, refreshed chan<- struct{}, forceRefresh <-chan refreshLockRequest, logger func(format string, args ...any)) {
debug.Log("start")
lock := unlocker.lock
ticker := time.NewTicker(l.refreshInterval)
@@ -185,7 +185,7 @@ func (l *locker) refreshLocks(ctx context.Context, backend backend.Backend, unlo
}
}
-func (l *locker) monitorLockRefresh(ctx context.Context, unlocker *unlocker, refreshed <-chan struct{}, forceRefresh chan<- refreshLockRequest, logger func(format string, args ...interface{})) {
+func (l *locker) monitorLockRefresh(ctx context.Context, unlocker *unlocker, refreshed <-chan struct{}, forceRefresh chan<- refreshLockRequest, logger func(format string, args ...any)) {
// time.Now() might use a monotonic timer which is paused during standby
// convert to unix time to ensure we compare real time values
lastRefresh := time.Now().UnixNano()
@@ -247,7 +247,7 @@ func (l *locker) monitorLockRefresh(ctx context.Context, unlocker *unlocker, ref
}
}
-func tryRefreshStaleLock(ctx context.Context, be backend.Backend, lock *lockHandle, cancel context.CancelFunc, logger func(format string, args ...interface{})) bool {
+func tryRefreshStaleLock(ctx context.Context, be backend.Backend, lock *lockHandle, cancel context.CancelFunc, logger func(format string, args ...any)) bool {
freeze := backend.AsBackend[backend.FreezeBackend](be)
if freeze != nil {
debug.Log("freezing backend")
diff --git a/internal/repository/lock_test.go b/internal/repository/lock_test.go
index 847be76e5..e0f01f788 100644
--- a/internal/repository/lock_test.go
+++ b/internal/repository/lock_test.go
@@ -35,7 +35,7 @@ func openLockTestRepo(t *testing.T, wrapper backendWrapper) (*Repository, backen
}
func checkedLockRepo(ctx context.Context, t *testing.T, repo *Repository, lockerInst *locker, retryLock time.Duration) (func(), context.Context) {
- unlock, wrappedCtx, err := lockerInst.Lock(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {})
+ unlock, wrappedCtx, err := lockerInst.Lock(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
rtest.OK(t, wrappedCtx.Err())
return unlock, wrappedCtx
@@ -73,10 +73,10 @@ func TestLockConflict(t *testing.T) {
repo, be := openLockTestRepo(t, nil)
repo2 := TestOpenBackend(t, be)
- unlock, _, err := LockRepo(context.Background(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {})
+ unlock, _, err := LockRepo(context.Background(), repo, true, 0, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
defer unlock()
- _, _, err = LockRepo(context.Background(), repo2, false, 0, func(msg string) {}, func(format string, args ...interface{}) {})
+ _, _, err = LockRepo(context.Background(), repo2, false, 0, func(msg string) {}, func(format string, args ...any) {})
if err == nil {
t.Fatal("second lock should have failed")
}
@@ -237,14 +237,14 @@ func TestLockWaitTimeout(t *testing.T) {
t.Parallel()
repo, _ := openLockTestRepo(t, nil)
- elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {})
+ elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
defer elock()
retryLock := 200 * time.Millisecond
start := time.Now()
- _, _, err = LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {})
+ _, _, err = LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...any) {})
duration := time.Since(start)
rtest.Assert(t, err != nil,
@@ -259,7 +259,7 @@ func TestLockWaitCancel(t *testing.T) {
t.Parallel()
repo, _ := openLockTestRepo(t, nil)
- elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {})
+ elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
defer elock()
@@ -270,7 +270,7 @@ func TestLockWaitCancel(t *testing.T) {
ctx, cancel := context.WithCancel(context.TODO())
time.AfterFunc(cancelAfter, cancel)
- _, _, err = LockRepo(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {})
+ _, _, err = LockRepo(ctx, repo, false, retryLock, func(msg string) {}, func(format string, args ...any) {})
duration := time.Since(start)
rtest.Assert(t, err != nil,
@@ -285,7 +285,7 @@ func TestLockWaitSuccess(t *testing.T) {
t.Parallel()
repo, _ := openLockTestRepo(t, nil)
- elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...interface{}) {})
+ elock, _, err := LockRepo(context.TODO(), repo, true, 0, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
retryLock := 200 * time.Millisecond
@@ -295,7 +295,7 @@ func TestLockWaitSuccess(t *testing.T) {
elock()
})
- unlock, _, err := LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...interface{}) {})
+ unlock, _, err := LockRepo(context.TODO(), repo, false, retryLock, func(msg string) {}, func(format string, args ...any) {})
rtest.OK(t, err)
unlock()
}
diff --git a/internal/repository/repack.go b/internal/repository/repack.go
index fb59a5c5a..910b871df 100644
--- a/internal/repository/repack.go
+++ b/internal/repository/repack.go
@@ -20,7 +20,7 @@ type repackBlobSet interface {
Len() int
}
-type LogFunc func(msg string, args ...interface{})
+type LogFunc func(msg string, args ...any)
// CopyBlobs takes a list of packs together with a list of blobs contained in
// these packs. Each pack is loaded and the blobs listed in keepBlobs is saved
@@ -42,7 +42,7 @@ func CopyBlobs(
debug.Log("repacking %d packs while keeping %d blobs", len(packs), keepBlobs.Len())
if logf == nil {
- logf = func(_ string, _ ...interface{}) {}
+ logf = func(_ string, _ ...any) {}
}
p.SetMax(uint64(len(packs)))
defer p.Done()
diff --git a/internal/repository/repository.go b/internal/repository/repository.go
index e52c01f11..8955164ae 100644
--- a/internal/repository/repository.go
+++ b/internal/repository/repository.go
@@ -163,7 +163,7 @@ func (r *Repository) PackSize() uint {
}
// UseCache replaces the backend with the wrapped cache.
-func (r *Repository) UseCache(c *cache.Cache, errorLog func(string, ...interface{})) {
+func (r *Repository) UseCache(c *cache.Cache, errorLog func(string, ...any)) {
if c == nil {
return
}
diff --git a/internal/repository/testing.go b/internal/repository/testing.go
index dc27be42d..86224bed7 100644
--- a/internal/repository/testing.go
+++ b/internal/repository/testing.go
@@ -20,7 +20,7 @@ import (
)
type logger interface {
- Logf(format string, args ...interface{})
+ Logf(format string, args ...any)
}
var paramsOnce sync.Once
diff --git a/internal/restic/json.go b/internal/restic/json.go
index ec64ff153..f4ae97e3e 100644
--- a/internal/restic/json.go
+++ b/internal/restic/json.go
@@ -10,7 +10,7 @@ import (
// LoadJSONUnpacked decrypts the data and afterwards calls json.Unmarshal on
// the item.
-func LoadJSONUnpacked(ctx context.Context, repo LoaderUnpacked, t FileType, id ID, item interface{}) (err error) {
+func LoadJSONUnpacked(ctx context.Context, repo LoaderUnpacked, t FileType, id ID, item any) (err error) {
buf, err := repo.LoadUnpacked(ctx, t, id)
if err != nil {
return err
@@ -21,7 +21,7 @@ func LoadJSONUnpacked(ctx context.Context, repo LoaderUnpacked, t FileType, id I
// SaveJSONUnpacked serialises item as JSON and encrypts and saves it in the
// backend as type t, without a pack. It returns the storage hash.
-func SaveJSONUnpacked[FT FileTypes](ctx context.Context, repo SaverUnpacked[FT], t FT, item interface{}) (ID, error) {
+func SaveJSONUnpacked[FT FileTypes](ctx context.Context, repo SaverUnpacked[FT], t FT, item any) (ID, error) {
debug.Log("save new blob %v", t)
plaintext, err := json.Marshal(item)
if err != nil {
diff --git a/internal/restic/progress.go b/internal/restic/progress.go
index e9ce10d58..3e6e3da6a 100644
--- a/internal/restic/progress.go
+++ b/internal/restic/progress.go
@@ -38,24 +38,24 @@ type Printer interface {
// E reports an error. This message is always printed to stderr.
// Appends a newline if not present.
- E(msg string, args ...interface{})
+ E(msg string, args ...any)
// S prints a message, this is should only be used for very important messages
// that are not errors. The message is even printed if --quiet is specified.
// Appends a newline if not present.
- S(msg string, args ...interface{})
+ S(msg string, args ...any)
// PT prints a message if verbosity >= 1 (neither --quiet nor --verbose is specified)
// and stdout points to a terminal.
// This is used for informational messages.
- PT(msg string, args ...interface{})
+ PT(msg string, args ...any)
// P prints a message if verbosity >= 1 (neither --quiet nor --verbose is specified),
// this is used for normal messages which are not errors. Appends a newline if not present.
- P(msg string, args ...interface{})
+ P(msg string, args ...any)
// V prints a message if verbosity >= 2 (equivalent to --verbose), this is used for
// verbose messages. Appends a newline if not present.
- V(msg string, args ...interface{})
+ V(msg string, args ...any)
// VV prints a message if verbosity >= 3 (equivalent to --verbose=2), this is used for
// debug messages. Appends a newline if not present.
- VV(msg string, args ...interface{})
+ VV(msg string, args ...any)
}
// noopPrinter discards all messages.
@@ -79,14 +79,14 @@ func (*noopPrinter) NewCounterTerminalOnly(_ string) Counter {
return NoopCounter
}
-func (*noopPrinter) E(_ string, _ ...interface{}) {}
+func (*noopPrinter) E(_ string, _ ...any) {}
-func (*noopPrinter) S(_ string, _ ...interface{}) {}
+func (*noopPrinter) S(_ string, _ ...any) {}
-func (*noopPrinter) PT(_ string, _ ...interface{}) {}
+func (*noopPrinter) PT(_ string, _ ...any) {}
-func (*noopPrinter) P(_ string, _ ...interface{}) {}
+func (*noopPrinter) P(_ string, _ ...any) {}
-func (*noopPrinter) V(_ string, _ ...interface{}) {}
+func (*noopPrinter) V(_ string, _ ...any) {}
-func (*noopPrinter) VV(_ string, _ ...interface{}) {}
+func (*noopPrinter) VV(_ string, _ ...any) {}
diff --git a/internal/restorer/filerestorer.go b/internal/restorer/filerestorer.go
index 76b2d31c7..0c5c4df44 100644
--- a/internal/restorer/filerestorer.go
+++ b/internal/restorer/filerestorer.go
@@ -24,8 +24,8 @@ type fileInfo struct {
inProgress bool
sparse bool
size int64
- location string // file on local filesystem relative to restorer basedir
- blobs interface{} // blobs of the file
+ location string // file on local filesystem relative to restorer basedir
+ blobs any // blobs of the file
state *fileState
}
diff --git a/internal/restorer/restorer_test.go b/internal/restorer/restorer_test.go
index 225c70aa5..420547192 100644
--- a/internal/restorer/restorer_test.go
+++ b/internal/restorer/restorer_test.go
@@ -26,7 +26,7 @@ import (
"github.com/restic/restic/internal/ui/progress"
)
-type Node interface{}
+type Node any
type Snapshot struct {
Nodes map[string]Node
diff --git a/internal/selfupdate/download.go b/internal/selfupdate/download.go
index 00721af80..11c62d78d 100644
--- a/internal/selfupdate/download.go
+++ b/internal/selfupdate/download.go
@@ -39,7 +39,7 @@ func findHash(buf []byte, filename string) (hash []byte, err error) {
return nil, fmt.Errorf("hash for file %v not found", filename)
}
-func extractToFile(buf []byte, filename, target string, printf func(string, ...interface{})) error {
+func extractToFile(buf []byte, filename, target string, printf func(string, ...any)) error {
var rd io.Reader = bytes.NewReader(buf)
switch filepath.Ext(filename) {
case ".bz2":
@@ -112,9 +112,9 @@ func extractToFile(buf []byte, filename, target string, printf func(string, ...i
// DownloadLatestStableRelease downloads the latest stable released version of
// restic and saves it to target. It returns the version string for the newest
// version. The function printf is used to print progress information.
-func DownloadLatestStableRelease(ctx context.Context, target, currentVersion string, printf func(string, ...interface{})) (version string, err error) {
+func DownloadLatestStableRelease(ctx context.Context, target, currentVersion string, printf func(string, ...any)) (version string, err error) {
if printf == nil {
- printf = func(string, ...interface{}) {}
+ printf = func(string, ...any) {}
}
printf("find latest release of restic at GitHub\n")
diff --git a/internal/selfupdate/download_test.go b/internal/selfupdate/download_test.go
index 00160eef2..f4788072d 100644
--- a/internal/selfupdate/download_test.go
+++ b/internal/selfupdate/download_test.go
@@ -11,7 +11,7 @@ import (
)
func TestExtractToFileZip(t *testing.T) {
- printf := func(string, ...interface{}) {}
+ printf := func(string, ...any) {}
dir := t.TempDir()
ext := "zip"
diff --git a/internal/selfupdate/github.go b/internal/selfupdate/github.go
index 8cb825b7b..eceaf1cfe 100644
--- a/internal/selfupdate/github.go
+++ b/internal/selfupdate/github.go
@@ -156,7 +156,7 @@ func getGithubData(ctx context.Context, url string) ([]byte, error) {
return buf, nil
}
-func getGithubDataFile(ctx context.Context, assets []Asset, suffix string, printf func(string, ...interface{})) (filename string, data []byte, err error) {
+func getGithubDataFile(ctx context.Context, assets []Asset, suffix string, printf func(string, ...any)) (filename string, data []byte, err error) {
var url string
for _, a := range assets {
if strings.HasSuffix(a.Name, suffix) {
diff --git a/internal/test/helpers.go b/internal/test/helpers.go
index 48fbf1259..019c5cb6c 100644
--- a/internal/test/helpers.go
+++ b/internal/test/helpers.go
@@ -16,7 +16,7 @@ import (
)
// Assert fails the test if the condition is false.
-func Assert(tb testing.TB, condition bool, msg string, v ...interface{}) {
+func Assert(tb testing.TB, condition bool, msg string, v ...any) {
tb.Helper()
if !condition {
tb.Fatalf("\033[31m"+msg+"\033[39m\n\n", v...)
@@ -56,7 +56,7 @@ func Equals[T any](tb testing.TB, exp, act T, msgs ...string) {
if length == 1 {
msgString = msgs[0]
} else if length > 1 {
- args := make([]interface{}, length-1)
+ args := make([]any, length-1)
for i, msg := range msgs[1:] {
args[i] = msg
}
diff --git a/internal/ui/backup/json.go b/internal/ui/backup/json.go
index 9c1b51599..98de622b7 100644
--- a/internal/ui/backup/json.go
+++ b/internal/ui/backup/json.go
@@ -30,11 +30,11 @@ func NewJSONProgress(term ui.Terminal, verbosity uint) ProgressPrinter {
}
}
-func (b *jsonProgress) print(status interface{}) {
+func (b *jsonProgress) print(status any) {
b.term.Print(ui.ToJSONString(status))
}
-func (b *jsonProgress) error(status interface{}) {
+func (b *jsonProgress) error(status any) {
b.term.Error(ui.ToJSONString(status))
}
diff --git a/internal/ui/format.go b/internal/ui/format.go
index 36dfa8147..bc39b4ae0 100644
--- a/internal/ui/format.go
+++ b/internal/ui/format.go
@@ -100,7 +100,7 @@ func ParseBytes(s string) (int64, error) {
return value, nil
}
-func ToJSONString(status interface{}) string {
+func ToJSONString(status any) string {
buf := new(bytes.Buffer)
err := json.NewEncoder(buf).Encode(status)
if err != nil {
diff --git a/internal/ui/progress/terminal.go b/internal/ui/progress/terminal.go
index 7f5428968..36c36b22a 100644
--- a/internal/ui/progress/terminal.go
+++ b/internal/ui/progress/terminal.go
@@ -66,33 +66,33 @@ func (t *terminalPrinter) NewCounterTerminalOnly(description string) restic.Coun
return newProgressMax(t.v > 0 && t.term.OutputIsTerminal(), 0, description, t.term)
}
-func (t *terminalPrinter) E(msg string, args ...interface{}) {
+func (t *terminalPrinter) E(msg string, args ...any) {
t.term.Error(fmt.Sprintf(msg, args...))
}
-func (t *terminalPrinter) S(msg string, args ...interface{}) {
+func (t *terminalPrinter) S(msg string, args ...any) {
t.term.Print(fmt.Sprintf(msg, args...))
}
-func (t *terminalPrinter) PT(msg string, args ...interface{}) {
+func (t *terminalPrinter) PT(msg string, args ...any) {
if t.term.OutputIsTerminal() && t.v >= 1 {
t.term.Print(fmt.Sprintf(msg, args...))
}
}
-func (t *terminalPrinter) P(msg string, args ...interface{}) {
+func (t *terminalPrinter) P(msg string, args ...any) {
if t.v >= 1 {
t.term.Print(fmt.Sprintf(msg, args...))
}
}
-func (t *terminalPrinter) V(msg string, args ...interface{}) {
+func (t *terminalPrinter) V(msg string, args ...any) {
if t.v >= 2 {
t.term.Print(fmt.Sprintf(msg, args...))
}
}
-func (t *terminalPrinter) VV(msg string, args ...interface{}) {
+func (t *terminalPrinter) VV(msg string, args ...any) {
if t.v >= 3 {
t.term.Print(fmt.Sprintf(msg, args...))
}
diff --git a/internal/ui/restore/json.go b/internal/ui/restore/json.go
index 4ce66fcbf..a4ae8829f 100644
--- a/internal/ui/restore/json.go
+++ b/internal/ui/restore/json.go
@@ -24,11 +24,11 @@ func NewJSONProgress(terminal ui.Terminal, verbosity uint) ProgressPrinter {
}
}
-func (t *jsonPrinter) print(status interface{}) {
+func (t *jsonPrinter) print(status any) {
t.terminal.Print(ui.ToJSONString(status))
}
-func (t *jsonPrinter) error(status interface{}) {
+func (t *jsonPrinter) error(status any) {
t.terminal.Error(ui.ToJSONString(status))
}
diff --git a/internal/ui/table/table.go b/internal/ui/table/table.go
index 2aff8cbb1..269df0419 100644
--- a/internal/ui/table/table.go
+++ b/internal/ui/table/table.go
@@ -13,7 +13,7 @@ import (
type Table struct {
columns []string
templates []*template.Template
- data []interface{}
+ data []any
footer []string
CellSeparator string
@@ -58,7 +58,7 @@ func (t *Table) AddColumn(header, format string) {
}
// AddRow adds a new row to the table, which is filled with data.
-func (t *Table) AddRow(data interface{}) {
+func (t *Table) AddRow(data any) {
t.data = append(t.data, data)
}
diff --git a/internal/walker/walker_test.go b/internal/walker/walker_test.go
index fad95476d..6f8a5529a 100644
--- a/internal/walker/walker_test.go
+++ b/internal/walker/walker_test.go
@@ -12,7 +12,7 @@ import (
)
// TestTree is used to construct a list of trees for testing the walker.
-type TestTree map[string]interface{}
+type TestTree map[string]any
// TestFile is used to test the walker.
type TestFile struct {