From 657fda216adc67b1da98e488bf5938a9dd97b065 Mon Sep 17 00:00:00 2001 From: Nathan Baulch Date: Wed, 12 Nov 2025 16:27:10 +1100 Subject: [PATCH] chore(ci): upgrade to golangci-lint 2.6.1 (#4973) - upgrade to golangci-lint 2.6.1 - updates for gosec - updates for govet - updates for perfsprint - updates modernize Leaves out modernize:omitempty due to conflicts with tests --- .golangci.yml | 3 +++ cli/command_blob_shards_modify.go | 4 ++-- cli/command_index_inspect.go | 9 ++------- cli/command_logs_show.go | 9 ++------- cli/command_maintenance_info.go | 9 +++++---- cli/command_notification_template_test.go | 7 +++---- cli/command_server_control_test.go | 9 ++------- cli/command_snapshot_fix_remove_files.go | 9 ++++----- cli/password_other.go | 1 - cli/sighup_unix.go | 1 - fs/localfs/local_fs_32bit.go | 2 -- fs/localfs/local_fs_64bit.go | 4 ---- fs/localfs/local_fs_nonwindows.go | 1 - internal/acl/acl.go | 7 +++---- internal/clock/now_prod.go | 1 - internal/clock/now_testing.go | 1 - .../crypto/pb_key_deriver_insecure_testing.go | 1 - internal/feature/feature.go | 9 ++------- internal/fusemount/fusefs.go | 1 - internal/indextest/indextest.go | 2 +- internal/listcache/listcache.go | 9 ++------- internal/mount/mount_fuse.go | 1 - internal/mount/mount_net_use.go | 1 - internal/mount/mount_posix_webdav_helper.go | 1 - internal/mount/mount_unsupported.go | 1 - internal/osexec/osexec_unix.go | 1 - internal/ospath/ospath_xdg.go | 1 - internal/server/htmlui_embed.go | 1 - internal/server/htmlui_fallback.go | 1 - internal/stat/stat_bsd.go | 1 - internal/stat/stat_test.go | 1 - internal/stat/stat_unix.go | 1 - internal/stat/stat_windows.go | 1 - .../tempfile/tempfile_linux_fallback_test.go | 1 - internal/tempfile/tempfile_unix_fallback.go | 1 - internal/tempfile/tempfile_unix_nonlinux.go | 1 - internal/testutil/norace.go | 1 - internal/testutil/race.go | 1 - internal/uitask/uitask_manager.go | 8 +------- .../filesystem_storage_capacity_openbsd.go | 1 - .../filesystem_storage_capacity_unix.go | 1 - .../filesystem_storage_capacity_windows.go | 1 - .../filesystem/filesystem_storage_unix_test.go | 1 - .../filesystem/osinterface_mock_other_test.go | 1 - .../filesystem/osinterface_mock_unix_test.go | 1 - repo/blob/filesystem/osinterface_realos_other.go | 1 - repo/blob/filesystem/osinterface_realos_unix.go | 1 - .../committed_content_index_disk_cache.go | 3 +-- repo/content/index/index_builder.go | 2 +- repo/ecc/ecc_rs_crc.go | 2 +- .../format_blob_key_derivation_nontesting.go | 1 - .../format/format_blob_key_derivation_testing.go | 1 - repo/manifest/serialized_test.go | 7 +++---- repo/object/object_manager_test.go | 7 +++---- snapshot/policy/policy_merge_test.go | 6 +++--- snapshot/restore/local_fs_output_unix.go | 1 - snapshot/restore/long_paths_unix.go | 1 - snapshot/upload/upload_os_snapshot_nonwindows.go | 1 - tests/end_to_end_test/norace_test.go | 1 - .../repository_set_client_test.go | 7 +++---- tests/end_to_end_test/snapshot_create_test.go | 7 +++---- .../os_snapshot_nonwindows_test.go | 1 - .../recovery/blobmanipulator/blobmanipulator.go | 1 - tests/recovery/recovery_test/main_test.go | 1 - tests/recovery/recovery_test/recovery_test.go | 1 - tests/robustness/checker/checker.go | 1 - tests/robustness/engine/action.go | 1 - tests/robustness/engine/engine.go | 1 - tests/robustness/engine/engine_test.go | 1 - tests/robustness/engine/log.go | 1 - tests/robustness/engine/metadata.go | 1 - tests/robustness/engine/stats.go | 1 - tests/robustness/errors.go | 1 - tests/robustness/filewriter.go | 1 - tests/robustness/fiofilewriter/fio_filewriter.go | 1 - .../multiclient_test/framework/client.go | 1 - .../multiclient_test/framework/filewriter.go | 1 - .../multiclient_test/framework/framework.go | 1 - .../multiclient_test/framework/harness.go | 1 - .../multiclient_test/framework/snapshotter.go | 1 - tests/robustness/multiclient_test/main_test.go | 1 - .../multiclient_test/multiclient_test.go | 1 - .../storagestats/storage_stats.go | 1 - tests/robustness/options.go | 1 - tests/robustness/persister.go | 1 - tests/robustness/robustness_test/main_test.go | 1 - .../robustness_test/robustness_test.go | 1 - tests/robustness/snapmeta/index.go | 1 - tests/robustness/snapmeta/index_test.go | 1 - tests/robustness/snapmeta/kopia_connector.go | 1 - .../robustness/snapmeta/kopia_connector_test.go | 1 - tests/robustness/snapmeta/kopia_persister.go | 1 - .../robustness/snapmeta/kopia_persister_light.go | 1 - .../snapmeta/kopia_persister_light_test.go | 1 - tests/robustness/snapmeta/kopia_snapshotter.go | 1 - .../snapmeta/kopia_snapshotter_upgrade_test.go | 1 - tests/robustness/snapmeta/simple.go | 1 - tests/robustness/snapmeta/simple_test.go | 1 - tests/robustness/snapshotter.go | 1 - .../socketactivation_test.go | 1 - tests/testdirtree/testdirtree.go | 8 +++++--- tests/tools/fswalker/fswalker.go | 1 - tests/tools/fswalker/fswalker_test.go | 1 - tests/tools/fswalker/reporter/reporter.go | 1 - tests/tools/fswalker/reporter/reporter_test.go | 1 - tests/tools/fswalker/walker/walker.go | 1 - tests/tools/fswalker/walker/walker_test.go | 1 - tests/tools/kopiaclient/kopiaclient.go | 1 - tests/tools/kopiarunner/setpdeath.go | 1 - tools/cli2md/cli2md.go | 16 +++++++++++----- tools/gettool/checksums.txt | 12 ++++++------ tools/tools.mk | 2 +- 112 files changed, 73 insertions(+), 191 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fbba11fa6..31e845512 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -80,6 +80,9 @@ linters: - (*go.uber.org/zap.SugaredLogger).With misspell: locale: US + modernize: + disable: + - omitzero wsl_v5: allow-whole-block: true disable: diff --git a/cli/command_blob_shards_modify.go b/cli/command_blob_shards_modify.go index 5012c71f6..20252098e 100644 --- a/cli/command_blob_shards_modify.go +++ b/cli/command_blob_shards_modify.go @@ -236,8 +236,8 @@ func (c *commandBlobShardsModify) renameBlobs(ctx context.Context, dir, prefix s if err := c.renameBlobs(ctx, path.Join(dir, ent.Name()), prefix+ent.Name(), params, numMoved, numUnchanged); err != nil { return err } - } else if strings.HasSuffix(ent.Name(), sharded.CompleteBlobSuffix) { - blobID := prefix + strings.TrimSuffix(ent.Name(), sharded.CompleteBlobSuffix) + } else if name, ok := strings.CutSuffix(ent.Name(), sharded.CompleteBlobSuffix); ok { + blobID := prefix + name destDir, destBlobID := params.GetShardDirectoryAndBlob(c.rootPath, blob.ID(blobID)) srcFile := path.Join(dir, ent.Name()) diff --git a/cli/command_index_inspect.go b/cli/command_index_inspect.go index f29ee63e5..2b53d322c 100644 --- a/cli/command_index_inspect.go +++ b/cli/command_index_inspect.go @@ -2,6 +2,7 @@ import ( "context" + "slices" "sync" "github.com/pkg/errors" @@ -134,13 +135,7 @@ func (c *commandIndexInspect) shouldInclude(ci content.Info) bool { contentID := ci.ContentID.String() - for _, cid := range c.contentIDs { - if cid == contentID { - return true - } - } - - return false + return slices.Contains(c.contentIDs, contentID) } type indexBlobPlusContentInfo struct { diff --git a/cli/command_logs_show.go b/cli/command_logs_show.go index f0726fd45..9c8efcd21 100644 --- a/cli/command_logs_show.go +++ b/cli/command_logs_show.go @@ -2,6 +2,7 @@ import ( "context" + "slices" "github.com/pkg/errors" @@ -38,13 +39,7 @@ func (c *commandLogsShow) run(ctx context.Context, rep repo.DirectRepository) er if len(c.logSessionIDs) > 0 { sessions = filterLogSessions(sessions, func(l *logSessionInfo) bool { - for _, sid := range c.logSessionIDs { - if l.id == sid { - return true - } - } - - return false + return slices.Contains(c.logSessionIDs, l.id) }) } diff --git a/cli/command_maintenance_info.go b/cli/command_maintenance_info.go index 995a36aae..042e1d5f1 100644 --- a/cli/command_maintenance_info.go +++ b/cli/command_maintenance_info.go @@ -2,6 +2,7 @@ import ( "context" + "strings" "time" "github.com/pkg/errors" @@ -123,16 +124,16 @@ func getMessageFromRun(extra []maintenancestats.Extra) string { return succeed } - extraStr := "" + var extraStr strings.Builder for _, e := range extra { if msg, err := maintenancestats.BuildFromExtra(e); err == nil { - extraStr += msg.Summary() + extraStr.WriteString(msg.Summary()) } } - if extraStr != "" { - succeed = ": " + extraStr + if extraStr.Len() > 0 { + succeed = ": " + extraStr.String() } return succeed diff --git a/cli/command_notification_template_test.go b/cli/command_notification_template_test.go index 20d34898e..061213203 100644 --- a/cli/command_notification_template_test.go +++ b/cli/command_notification_template_test.go @@ -3,6 +3,7 @@ import ( "context" "os" + "slices" "strings" "testing" @@ -124,10 +125,8 @@ func verifyTemplateContents(t *testing.T, e *testenv.CLITest, templateName strin func verifyHasLine(t *testing.T, lines []string, ok func(s string) bool) { t.Helper() - for _, l := range lines { - if ok(l) { - return - } + if slices.ContainsFunc(lines, ok) { + return } t.Errorf("output line meeting given condition was not found: %v", lines) diff --git a/cli/command_server_control_test.go b/cli/command_server_control_test.go index 08927a74c..953a3de8a 100644 --- a/cli/command_server_control_test.go +++ b/cli/command_server_control_test.go @@ -2,6 +2,7 @@ import ( "runtime" + "slices" "testing" "time" @@ -221,11 +222,5 @@ func TestServerControlUDS(t *testing.T) { } func hasLine(lines []string, lookFor string) bool { - for _, l := range lines { - if l == lookFor { - return true - } - } - - return false + return slices.Contains(lines, lookFor) } diff --git a/cli/command_snapshot_fix_remove_files.go b/cli/command_snapshot_fix_remove_files.go index 8d5f8323c..152c32b7b 100644 --- a/cli/command_snapshot_fix_remove_files.go +++ b/cli/command_snapshot_fix_remove_files.go @@ -3,6 +3,7 @@ import ( "context" "path" + "slices" "github.com/pkg/errors" @@ -28,12 +29,10 @@ func (c *commandSnapshotFixRemoveFiles) setup(svc appServices, parent commandPar } func (c *commandSnapshotFixRemoveFiles) rewriteEntry(ctx context.Context, pathFromRoot string, ent *snapshot.DirEntry) (*snapshot.DirEntry, error) { - for _, id := range c.removeObjectIDs { - if ent.ObjectID.String() == id { - log(ctx).Infof("will remove file %v", pathFromRoot) + if slices.Contains(c.removeObjectIDs, ent.ObjectID.String()) { + log(ctx).Infof("will remove file %v", pathFromRoot) - return nil, nil - } + return nil, nil } for _, n := range c.removeFilesByName { diff --git a/cli/password_other.go b/cli/password_other.go index 6e0d0b0e2..2d9a464c0 100644 --- a/cli/password_other.go +++ b/cli/password_other.go @@ -1,5 +1,4 @@ //go:build !windows && !linux && !darwin -// +build !windows,!linux,!darwin package cli diff --git a/cli/sighup_unix.go b/cli/sighup_unix.go index 6284ad808..de662f049 100644 --- a/cli/sighup_unix.go +++ b/cli/sighup_unix.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package cli diff --git a/fs/localfs/local_fs_32bit.go b/fs/localfs/local_fs_32bit.go index 361b705c1..a7e73b0f7 100644 --- a/fs/localfs/local_fs_32bit.go +++ b/fs/localfs/local_fs_32bit.go @@ -1,6 +1,4 @@ //go:build !windows && ((!amd64 && !arm64 && !arm && !ppc64 && !ppc64le && !s390x && !386 && !riscv64) || darwin || openbsd) -// +build !windows -// +build !amd64,!arm64,!arm,!ppc64,!ppc64le,!s390x,!386,!riscv64 darwin openbsd package localfs diff --git a/fs/localfs/local_fs_64bit.go b/fs/localfs/local_fs_64bit.go index bb0ce6ee9..5c86dac9f 100644 --- a/fs/localfs/local_fs_64bit.go +++ b/fs/localfs/local_fs_64bit.go @@ -1,8 +1,4 @@ //go:build !windows && !openbsd && !darwin && (amd64 || arm64 || arm || ppc64 || ppc64le || s390x || 386 || riscv64) -// +build !windows -// +build !openbsd -// +build !darwin -// +build amd64 arm64 arm ppc64 ppc64le s390x 386 riscv64 package localfs diff --git a/fs/localfs/local_fs_nonwindows.go b/fs/localfs/local_fs_nonwindows.go index 342da5a5a..4007f81e7 100644 --- a/fs/localfs/local_fs_nonwindows.go +++ b/fs/localfs/local_fs_nonwindows.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package localfs diff --git a/internal/acl/acl.go b/internal/acl/acl.go index 4b709cd22..727906e16 100644 --- a/internal/acl/acl.go +++ b/internal/acl/acl.go @@ -2,6 +2,7 @@ import ( "fmt" + "slices" "sort" "strings" @@ -81,10 +82,8 @@ func nonEmptyString(v string) error { func oneOf(allowed ...string) valueValidatorFunc { return func(v string) error { - for _, a := range allowed { - if v == a { - return nil - } + if slices.Contains(allowed, v) { + return nil } return errors.Errorf("must be one of: %v", strings.Join(allowed, ", ")) diff --git a/internal/clock/now_prod.go b/internal/clock/now_prod.go index 01548c11b..c6f02e99c 100644 --- a/internal/clock/now_prod.go +++ b/internal/clock/now_prod.go @@ -1,5 +1,4 @@ //go:build !testing -// +build !testing package clock diff --git a/internal/clock/now_testing.go b/internal/clock/now_testing.go index f0e6d2588..a900b5458 100644 --- a/internal/clock/now_testing.go +++ b/internal/clock/now_testing.go @@ -1,5 +1,4 @@ //go:build testing -// +build testing package clock diff --git a/internal/crypto/pb_key_deriver_insecure_testing.go b/internal/crypto/pb_key_deriver_insecure_testing.go index 961e71f22..698eb7322 100644 --- a/internal/crypto/pb_key_deriver_insecure_testing.go +++ b/internal/crypto/pb_key_deriver_insecure_testing.go @@ -1,5 +1,4 @@ //go:build testing -// +build testing package crypto diff --git a/internal/feature/feature.go b/internal/feature/feature.go index e17885205..35e09dff6 100644 --- a/internal/feature/feature.go +++ b/internal/feature/feature.go @@ -4,6 +4,7 @@ import ( "fmt" + "slices" ) // IfNotUnderstood describes the behavior of Kopia when a required feature is not understood. @@ -58,11 +59,5 @@ func GetUnsupportedFeatures(required []Required, supported []Feature) []Required } func isSupported(req Required, supported []Feature) bool { - for _, s := range supported { - if req.Feature == s { - return true - } - } - - return false + return slices.Contains(supported, req.Feature) } diff --git a/internal/fusemount/fusefs.go b/internal/fusemount/fusefs.go index 3c39af253..435b5377d 100644 --- a/internal/fusemount/fusefs.go +++ b/internal/fusemount/fusefs.go @@ -1,5 +1,4 @@ //go:build !windows && !openbsd && !freebsd -// +build !windows,!openbsd,!freebsd // Package fusemount implements FUSE filesystem nodes for mounting contents of filesystem stored in repository. // diff --git a/internal/indextest/indextest.go b/internal/indextest/indextest.go index a405db962..29122d2e0 100644 --- a/internal/indextest/indextest.go +++ b/internal/indextest/indextest.go @@ -61,7 +61,7 @@ func InfoDiff(i1, i2 index.Info, ignore ...string) []string { // dear future reader, if this fails because the number of methods has changed, // you need to add additional verification above. - if cnt := reflect.TypeOf(index.Info{}).NumMethod(); cnt != 1 { + if cnt := reflect.TypeFor[index.Info]().NumMethod(); cnt != 1 { diffs = append(diffs, fmt.Sprintf("unexpected number of methods on content.Info: %v, must update the test", cnt)) } diff --git a/internal/listcache/listcache.go b/internal/listcache/listcache.go index 8dea982a1..8cef5cfdb 100644 --- a/internal/listcache/listcache.go +++ b/internal/listcache/listcache.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" + "slices" "strings" "time" @@ -140,13 +141,7 @@ func (s *listCacheStorage) DeleteBlob(ctx context.Context, blobID blob.ID) error } func (s *listCacheStorage) isCachedPrefix(prefix blob.ID) bool { - for _, p := range s.prefixes { - if prefix == p { - return true - } - } - - return false + return slices.Contains(s.prefixes, prefix) } func (s *listCacheStorage) invalidateAfterUpdate(ctx context.Context, blobID blob.ID) { diff --git a/internal/mount/mount_fuse.go b/internal/mount/mount_fuse.go index 1d811fb22..97c6d5965 100644 --- a/internal/mount/mount_fuse.go +++ b/internal/mount/mount_fuse.go @@ -1,5 +1,4 @@ //go:build !windows && !freebsd && !openbsd -// +build !windows,!freebsd,!openbsd package mount diff --git a/internal/mount/mount_net_use.go b/internal/mount/mount_net_use.go index 83374b58a..b5987d94b 100644 --- a/internal/mount/mount_net_use.go +++ b/internal/mount/mount_net_use.go @@ -1,5 +1,4 @@ //go:build windows -// +build windows package mount diff --git a/internal/mount/mount_posix_webdav_helper.go b/internal/mount/mount_posix_webdav_helper.go index 43cd899b6..02e36aadc 100644 --- a/internal/mount/mount_posix_webdav_helper.go +++ b/internal/mount/mount_posix_webdav_helper.go @@ -1,5 +1,4 @@ //go:build !windows && !freebsd && !openbsd -// +build !windows,!freebsd,!openbsd package mount diff --git a/internal/mount/mount_unsupported.go b/internal/mount/mount_unsupported.go index cc4fb24f9..9258c2068 100644 --- a/internal/mount/mount_unsupported.go +++ b/internal/mount/mount_unsupported.go @@ -1,5 +1,4 @@ //go:build freebsd || openbsd -// +build freebsd openbsd package mount diff --git a/internal/osexec/osexec_unix.go b/internal/osexec/osexec_unix.go index 5446b9f1a..9f74debc2 100644 --- a/internal/osexec/osexec_unix.go +++ b/internal/osexec/osexec_unix.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package osexec diff --git a/internal/ospath/ospath_xdg.go b/internal/ospath/ospath_xdg.go index 875b49636..3f7e81121 100644 --- a/internal/ospath/ospath_xdg.go +++ b/internal/ospath/ospath_xdg.go @@ -1,5 +1,4 @@ //go:build !windows && !darwin && !openbsd -// +build !windows,!darwin,!openbsd package ospath diff --git a/internal/server/htmlui_embed.go b/internal/server/htmlui_embed.go index fbd6eb11d..762986d1d 100644 --- a/internal/server/htmlui_embed.go +++ b/internal/server/htmlui_embed.go @@ -1,5 +1,4 @@ //go:build !nohtmlui -// +build !nohtmlui package server diff --git a/internal/server/htmlui_fallback.go b/internal/server/htmlui_fallback.go index 102ade083..d0f2018a0 100644 --- a/internal/server/htmlui_fallback.go +++ b/internal/server/htmlui_fallback.go @@ -1,5 +1,4 @@ //go:build nohtmlui -// +build nohtmlui package server diff --git a/internal/stat/stat_bsd.go b/internal/stat/stat_bsd.go index 92b4a5e7d..056f43030 100644 --- a/internal/stat/stat_bsd.go +++ b/internal/stat/stat_bsd.go @@ -1,5 +1,4 @@ //go:build openbsd -// +build openbsd // Package stat provides a cross-platform abstraction for // common stat commands. diff --git a/internal/stat/stat_test.go b/internal/stat/stat_test.go index 143920764..168c2cdb1 100644 --- a/internal/stat/stat_test.go +++ b/internal/stat/stat_test.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package stat diff --git a/internal/stat/stat_unix.go b/internal/stat/stat_unix.go index a0555cc98..4745140a9 100644 --- a/internal/stat/stat_unix.go +++ b/internal/stat/stat_unix.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin -// +build linux freebsd darwin // Package stat provides a cross-platform abstraction for common stat commands. package stat diff --git a/internal/stat/stat_windows.go b/internal/stat/stat_windows.go index 7220b7207..29d6872c5 100644 --- a/internal/stat/stat_windows.go +++ b/internal/stat/stat_windows.go @@ -1,5 +1,4 @@ //go:build windows -// +build windows // Package stat provides a cross-platform abstraction for // common stat commands. diff --git a/internal/tempfile/tempfile_linux_fallback_test.go b/internal/tempfile/tempfile_linux_fallback_test.go index dbc88e48e..58973a084 100644 --- a/internal/tempfile/tempfile_linux_fallback_test.go +++ b/internal/tempfile/tempfile_linux_fallback_test.go @@ -1,5 +1,4 @@ //go:build linux -// +build linux package tempfile diff --git a/internal/tempfile/tempfile_unix_fallback.go b/internal/tempfile/tempfile_unix_fallback.go index f1ac3cb00..96d62c49d 100644 --- a/internal/tempfile/tempfile_unix_fallback.go +++ b/internal/tempfile/tempfile_unix_fallback.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin || openbsd -// +build linux freebsd darwin openbsd package tempfile diff --git a/internal/tempfile/tempfile_unix_nonlinux.go b/internal/tempfile/tempfile_unix_nonlinux.go index b0f28acc4..3a4ae8506 100644 --- a/internal/tempfile/tempfile_unix_nonlinux.go +++ b/internal/tempfile/tempfile_unix_nonlinux.go @@ -1,5 +1,4 @@ //go:build freebsd || darwin || openbsd -// +build freebsd darwin openbsd package tempfile diff --git a/internal/testutil/norace.go b/internal/testutil/norace.go index d1855196e..0d242f18c 100644 --- a/internal/testutil/norace.go +++ b/internal/testutil/norace.go @@ -1,5 +1,4 @@ //go:build !race -// +build !race package testutil diff --git a/internal/testutil/race.go b/internal/testutil/race.go index 2e50295f2..bb636cd09 100644 --- a/internal/testutil/race.go +++ b/internal/testutil/race.go @@ -1,5 +1,4 @@ //go:build race -// +build race package testutil diff --git a/internal/uitask/uitask_manager.go b/internal/uitask/uitask_manager.go index 4e36012e3..451210923 100644 --- a/internal/uitask/uitask_manager.go +++ b/internal/uitask/uitask_manager.go @@ -106,13 +106,7 @@ func (m *Manager) WaitForTask(ctx context.Context, taskID string, maxWaitTime ti deadline := clock.Now().Add(maxWaitTime) - sleepInterval := min( - //nolint:mnd - maxWaitTime/10, maxWaitInterval) - - if sleepInterval < minWaitInterval { - sleepInterval = minWaitInterval - } + sleepInterval := max(min(maxWaitTime/10, maxWaitInterval), minWaitInterval) //nolint:mnd for maxWaitTime < 0 || clock.Now().Before(deadline) { if !clock.SleepInterruptibly(ctx, sleepInterval) { diff --git a/repo/blob/filesystem/filesystem_storage_capacity_openbsd.go b/repo/blob/filesystem/filesystem_storage_capacity_openbsd.go index 8eaf31ae3..c26a877d1 100644 --- a/repo/blob/filesystem/filesystem_storage_capacity_openbsd.go +++ b/repo/blob/filesystem/filesystem_storage_capacity_openbsd.go @@ -1,5 +1,4 @@ //go:build openbsd -// +build openbsd package filesystem diff --git a/repo/blob/filesystem/filesystem_storage_capacity_unix.go b/repo/blob/filesystem/filesystem_storage_capacity_unix.go index d3057c345..b62431696 100644 --- a/repo/blob/filesystem/filesystem_storage_capacity_unix.go +++ b/repo/blob/filesystem/filesystem_storage_capacity_unix.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin -// +build linux freebsd darwin package filesystem diff --git a/repo/blob/filesystem/filesystem_storage_capacity_windows.go b/repo/blob/filesystem/filesystem_storage_capacity_windows.go index 4a2cf4439..4780befc4 100644 --- a/repo/blob/filesystem/filesystem_storage_capacity_windows.go +++ b/repo/blob/filesystem/filesystem_storage_capacity_windows.go @@ -1,5 +1,4 @@ //go:build windows -// +build windows package filesystem diff --git a/repo/blob/filesystem/filesystem_storage_unix_test.go b/repo/blob/filesystem/filesystem_storage_unix_test.go index 362c4bf7b..78b49ccb9 100644 --- a/repo/blob/filesystem/filesystem_storage_unix_test.go +++ b/repo/blob/filesystem/filesystem_storage_unix_test.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin -// +build linux freebsd darwin package filesystem diff --git a/repo/blob/filesystem/osinterface_mock_other_test.go b/repo/blob/filesystem/osinterface_mock_other_test.go index 7d6f89913..f75e59872 100644 --- a/repo/blob/filesystem/osinterface_mock_other_test.go +++ b/repo/blob/filesystem/osinterface_mock_other_test.go @@ -1,5 +1,4 @@ //go:build !linux && !freebsd && !darwin -// +build !linux,!freebsd,!darwin package filesystem diff --git a/repo/blob/filesystem/osinterface_mock_unix_test.go b/repo/blob/filesystem/osinterface_mock_unix_test.go index 271d30cb4..d2ae3143a 100644 --- a/repo/blob/filesystem/osinterface_mock_unix_test.go +++ b/repo/blob/filesystem/osinterface_mock_unix_test.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin -// +build linux freebsd darwin package filesystem diff --git a/repo/blob/filesystem/osinterface_realos_other.go b/repo/blob/filesystem/osinterface_realos_other.go index 8e9be018e..3b18b56be 100644 --- a/repo/blob/filesystem/osinterface_realos_other.go +++ b/repo/blob/filesystem/osinterface_realos_other.go @@ -1,5 +1,4 @@ //go:build !linux && !freebsd && !darwin -// +build !linux,!freebsd,!darwin package filesystem diff --git a/repo/blob/filesystem/osinterface_realos_unix.go b/repo/blob/filesystem/osinterface_realos_unix.go index b18afbb9c..7ce2170b1 100644 --- a/repo/blob/filesystem/osinterface_realos_unix.go +++ b/repo/blob/filesystem/osinterface_realos_unix.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || darwin -// +build linux freebsd darwin package filesystem diff --git a/repo/content/committed_content_index_disk_cache.go b/repo/content/committed_content_index_disk_cache.go index de655a36f..6a65908c9 100644 --- a/repo/content/committed_content_index_disk_cache.go +++ b/repo/content/committed_content_index_disk_cache.go @@ -143,8 +143,7 @@ func (c *diskCommittedContentIndexCache) expireUnused(ctx context.Context, used return errors.Wrap(err, "failed to read file info") } - if strings.HasSuffix(ent.Name(), simpleIndexSuffix) { - n := strings.TrimSuffix(ent.Name(), simpleIndexSuffix) + if n, ok := strings.CutSuffix(ent.Name(), simpleIndexSuffix); ok { remaining[blob.ID(n)] = fi } } diff --git a/repo/content/index/index_builder.go b/repo/content/index/index_builder.go index a102df6c4..dde6c45e0 100644 --- a/repo/content/index/index_builder.go +++ b/repo/content/index/index_builder.go @@ -97,7 +97,7 @@ func (b Builder) sortedContents() []*Info { // Phase 3 - merge results from all buckets. result := make([]*Info, 0, len(b)) - for i := range len(buckets) { //nolint:intrange + for i := range buckets { result = append(result, buckets[i]...) } diff --git a/repo/ecc/ecc_rs_crc.go b/repo/ecc/ecc_rs_crc.go index dfbd15170..da57ce52a 100644 --- a/repo/ecc/ecc_rs_crc.go +++ b/repo/ecc/ecc_rs_crc.go @@ -351,7 +351,7 @@ func readLength(shards [][]byte, sizes *sizesInfo) (originalSize, startShard, st startShard = 4 startByte = 0 - for i := range 4 { + for i := range lengthBuffer { lengthBuffer[i] = shards[i][0] } diff --git a/repo/format/format_blob_key_derivation_nontesting.go b/repo/format/format_blob_key_derivation_nontesting.go index 40170ffc0..12079baca 100644 --- a/repo/format/format_blob_key_derivation_nontesting.go +++ b/repo/format/format_blob_key_derivation_nontesting.go @@ -1,5 +1,4 @@ //go:build !testing -// +build !testing package format diff --git a/repo/format/format_blob_key_derivation_testing.go b/repo/format/format_blob_key_derivation_testing.go index 171e7d4e8..2a75c9148 100644 --- a/repo/format/format_blob_key_derivation_testing.go +++ b/repo/format/format_blob_key_derivation_testing.go @@ -1,5 +1,4 @@ //go:build testing -// +build testing package format diff --git a/repo/manifest/serialized_test.go b/repo/manifest/serialized_test.go index 5f5971aca..a82ed042c 100644 --- a/repo/manifest/serialized_test.go +++ b/repo/manifest/serialized_test.go @@ -5,6 +5,7 @@ "encoding/json" "fmt" "reflect" + "slices" "strings" "testing" "time" @@ -37,10 +38,8 @@ func checkPopulated( ) } - for _, typ := range ignoreTypeSubfields { - if typ == v.Type() { - return - } + if slices.Contains(ignoreTypeSubfields, v.Type()) { + return } switch v.Kind() { diff --git a/repo/object/object_manager_test.go b/repo/object/object_manager_test.go index 414b790fe..4913b315d 100644 --- a/repo/object/object_manager_test.go +++ b/repo/object/object_manager_test.go @@ -11,6 +11,7 @@ "math/rand" "runtime" "runtime/debug" + "slices" "sync" "testing" @@ -393,10 +394,8 @@ func TestObjectWriterRaceBetweenCheckpointAndResult(t *testing.T) { return errors.Wrapf(err, "Checkpoint() returned invalid object %v", cpID) } - for _, id := range ids { - if id == content.EmptyID { - return errors.New("checkpoint returned empty id") - } + if slices.Contains(ids, content.EmptyID) { + return errors.New("checkpoint returned empty id") } } diff --git a/snapshot/policy/policy_merge_test.go b/snapshot/policy/policy_merge_test.go index 8a2868046..3fd150caa 100644 --- a/snapshot/policy/policy_merge_test.go +++ b/snapshot/policy/policy_merge_test.go @@ -25,13 +25,13 @@ func TestPolicyDefinition(t *testing.T) { // verify that each field in the policy struct recursively matches a corresponding field // from the policy.Definition() struct. - ensureTypesMatch(t, reflect.TypeOf(policy.Policy{}), reflect.TypeOf(policy.Definition{})) + ensureTypesMatch(t, reflect.TypeFor[policy.Policy](), reflect.TypeFor[policy.Definition]()) } func ensureTypesMatch(t *testing.T, policyType, definitionType reflect.Type) { t.Helper() - sourceInfoType := reflect.TypeOf(snapshot.SourceInfo{}) + sourceInfoType := reflect.TypeFor[snapshot.SourceInfo]() for i := range policyType.NumField() { f := policyType.Field(i) @@ -57,7 +57,7 @@ func ensureTypesMatch(t *testing.T, policyType, definitionType reflect.Type) { } func TestPolicyMerge(t *testing.T) { - testPolicyMerge(t, reflect.TypeOf(policy.Policy{}), reflect.TypeOf(policy.Definition{}), "") + testPolicyMerge(t, reflect.TypeFor[policy.Policy](), reflect.TypeFor[policy.Definition](), "") } //nolint:thelper diff --git a/snapshot/restore/local_fs_output_unix.go b/snapshot/restore/local_fs_output_unix.go index 852c607f5..8e3d5e965 100644 --- a/snapshot/restore/local_fs_output_unix.go +++ b/snapshot/restore/local_fs_output_unix.go @@ -1,5 +1,4 @@ //go:build linux || freebsd || openbsd -// +build linux freebsd openbsd package restore diff --git a/snapshot/restore/long_paths_unix.go b/snapshot/restore/long_paths_unix.go index e6584dd2f..7f25dfa5c 100644 --- a/snapshot/restore/long_paths_unix.go +++ b/snapshot/restore/long_paths_unix.go @@ -1,5 +1,4 @@ //go:build !windows && !plan9 -// +build !windows,!plan9 package restore diff --git a/snapshot/upload/upload_os_snapshot_nonwindows.go b/snapshot/upload/upload_os_snapshot_nonwindows.go index 0216762c7..ec969cdee 100644 --- a/snapshot/upload/upload_os_snapshot_nonwindows.go +++ b/snapshot/upload/upload_os_snapshot_nonwindows.go @@ -1,5 +1,4 @@ //go:build !windows -// +build !windows package upload diff --git a/tests/end_to_end_test/norace_test.go b/tests/end_to_end_test/norace_test.go index 1673ed9c9..1b1ea4e0b 100644 --- a/tests/end_to_end_test/norace_test.go +++ b/tests/end_to_end_test/norace_test.go @@ -1,5 +1,4 @@ //go:build !race -// +build !race package endtoend_test diff --git a/tests/end_to_end_test/repository_set_client_test.go b/tests/end_to_end_test/repository_set_client_test.go index 6465199ed..b9e2e709a 100644 --- a/tests/end_to_end_test/repository_set_client_test.go +++ b/tests/end_to_end_test/repository_set_client_test.go @@ -1,6 +1,7 @@ package endtoend_test import ( + "slices" "strings" "testing" @@ -75,10 +76,8 @@ func (s *formatSpecificTestSuite) TestRepositorySetClient(t *testing.T) { func verifyHasLine(t *testing.T, lines []string, ok func(s string) bool) { t.Helper() - for _, l := range lines { - if ok(l) { - return - } + if slices.ContainsFunc(lines, ok) { + return } t.Errorf("output line meeting given condition was not found") diff --git a/tests/end_to_end_test/snapshot_create_test.go b/tests/end_to_end_test/snapshot_create_test.go index 3530bcad0..08a00ceca 100644 --- a/tests/end_to_end_test/snapshot_create_test.go +++ b/tests/end_to_end_test/snapshot_create_test.go @@ -6,6 +6,7 @@ "path/filepath" "reflect" "runtime" + "slices" "sort" "strings" "testing" @@ -643,10 +644,8 @@ func TestSnapshotCreateWithStdinStream(t *testing.T) { } func appendIfMissing(slice []string, i string) []string { - for _, ele := range slice { - if ele == i { - return slice - } + if slices.Contains(slice, i) { + return slice } return append(slice, i) diff --git a/tests/os_snapshot_test/os_snapshot_nonwindows_test.go b/tests/os_snapshot_test/os_snapshot_nonwindows_test.go index 37cf10ed3..88ebf900d 100644 --- a/tests/os_snapshot_test/os_snapshot_nonwindows_test.go +++ b/tests/os_snapshot_test/os_snapshot_nonwindows_test.go @@ -1,4 +1,3 @@ //go:build !windows -// +build !windows package os_snapshot_test diff --git a/tests/recovery/blobmanipulator/blobmanipulator.go b/tests/recovery/blobmanipulator/blobmanipulator.go index ed24eca2c..883ad706b 100644 --- a/tests/recovery/blobmanipulator/blobmanipulator.go +++ b/tests/recovery/blobmanipulator/blobmanipulator.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package blobmanipulator provides the framework for snapshot fix testing. package blobmanipulator diff --git a/tests/recovery/recovery_test/main_test.go b/tests/recovery/recovery_test/main_test.go index 625cdbcee..38ccc8cce 100644 --- a/tests/recovery/recovery_test/main_test.go +++ b/tests/recovery/recovery_test/main_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package recovery diff --git a/tests/recovery/recovery_test/recovery_test.go b/tests/recovery/recovery_test/recovery_test.go index d0b5479b8..0f646bf26 100644 --- a/tests/recovery/recovery_test/recovery_test.go +++ b/tests/recovery/recovery_test/recovery_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package recovery diff --git a/tests/robustness/checker/checker.go b/tests/robustness/checker/checker.go index 08bc2ccbb..417443221 100644 --- a/tests/robustness/checker/checker.go +++ b/tests/robustness/checker/checker.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package checker defines the framework for creating and restoring snapshots // with a data integrity check diff --git a/tests/robustness/engine/action.go b/tests/robustness/engine/action.go index 9134b185f..afaf59b3d 100644 --- a/tests/robustness/engine/action.go +++ b/tests/robustness/engine/action.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package engine diff --git a/tests/robustness/engine/engine.go b/tests/robustness/engine/engine.go index 70e3e2f98..8c1e4ff64 100644 --- a/tests/robustness/engine/engine.go +++ b/tests/robustness/engine/engine.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package engine provides the framework for a snapshot repository testing engine package engine diff --git a/tests/robustness/engine/engine_test.go b/tests/robustness/engine/engine_test.go index af2c5614b..d50db604f 100644 --- a/tests/robustness/engine/engine_test.go +++ b/tests/robustness/engine/engine_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package engine diff --git a/tests/robustness/engine/log.go b/tests/robustness/engine/log.go index 1545af096..5f7709b7f 100644 --- a/tests/robustness/engine/log.go +++ b/tests/robustness/engine/log.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package engine diff --git a/tests/robustness/engine/metadata.go b/tests/robustness/engine/metadata.go index b1bb77232..1b3163239 100644 --- a/tests/robustness/engine/metadata.go +++ b/tests/robustness/engine/metadata.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package engine diff --git a/tests/robustness/engine/stats.go b/tests/robustness/engine/stats.go index 6e694a3c4..79e0b77be 100644 --- a/tests/robustness/engine/stats.go +++ b/tests/robustness/engine/stats.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package engine diff --git a/tests/robustness/errors.go b/tests/robustness/errors.go index 198856e5d..9fed1a363 100644 --- a/tests/robustness/errors.go +++ b/tests/robustness/errors.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/filewriter.go b/tests/robustness/filewriter.go index 15b31aff5..c9d516f69 100644 --- a/tests/robustness/filewriter.go +++ b/tests/robustness/filewriter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/fiofilewriter/fio_filewriter.go b/tests/robustness/fiofilewriter/fio_filewriter.go index 4c5fbfb44..00ad223c0 100644 --- a/tests/robustness/fiofilewriter/fio_filewriter.go +++ b/tests/robustness/fiofilewriter/fio_filewriter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package fiofilewriter provides a FileWriter based on FIO. package fiofilewriter diff --git a/tests/robustness/multiclient_test/framework/client.go b/tests/robustness/multiclient_test/framework/client.go index 7704bcdb3..266b3c9cc 100644 --- a/tests/robustness/multiclient_test/framework/client.go +++ b/tests/robustness/multiclient_test/framework/client.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package framework diff --git a/tests/robustness/multiclient_test/framework/filewriter.go b/tests/robustness/multiclient_test/framework/filewriter.go index 8ae554924..fbdafeedb 100644 --- a/tests/robustness/multiclient_test/framework/filewriter.go +++ b/tests/robustness/multiclient_test/framework/filewriter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package framework diff --git a/tests/robustness/multiclient_test/framework/framework.go b/tests/robustness/multiclient_test/framework/framework.go index f05ebcd6c..e7610d25d 100644 --- a/tests/robustness/multiclient_test/framework/framework.go +++ b/tests/robustness/multiclient_test/framework/framework.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package framework contains tools to enable multiple clients to connect to a // central repository server and run robustness tests concurrently. diff --git a/tests/robustness/multiclient_test/framework/harness.go b/tests/robustness/multiclient_test/framework/harness.go index 0c7d7662e..214ea928b 100644 --- a/tests/robustness/multiclient_test/framework/harness.go +++ b/tests/robustness/multiclient_test/framework/harness.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package framework diff --git a/tests/robustness/multiclient_test/framework/snapshotter.go b/tests/robustness/multiclient_test/framework/snapshotter.go index 39b690d4e..c212ce194 100644 --- a/tests/robustness/multiclient_test/framework/snapshotter.go +++ b/tests/robustness/multiclient_test/framework/snapshotter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package framework diff --git a/tests/robustness/multiclient_test/main_test.go b/tests/robustness/multiclient_test/main_test.go index a0b59e762..5502512a7 100644 --- a/tests/robustness/multiclient_test/main_test.go +++ b/tests/robustness/multiclient_test/main_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package multiclienttest diff --git a/tests/robustness/multiclient_test/multiclient_test.go b/tests/robustness/multiclient_test/multiclient_test.go index 08304caac..a1f1c477e 100644 --- a/tests/robustness/multiclient_test/multiclient_test.go +++ b/tests/robustness/multiclient_test/multiclient_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package multiclienttest diff --git a/tests/robustness/multiclient_test/storagestats/storage_stats.go b/tests/robustness/multiclient_test/storagestats/storage_stats.go index f1faf605b..b6863e279 100644 --- a/tests/robustness/multiclient_test/storagestats/storage_stats.go +++ b/tests/robustness/multiclient_test/storagestats/storage_stats.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package storagestats contains logging mechanism // log disk space consumed by directories created by diff --git a/tests/robustness/options.go b/tests/robustness/options.go index 7af37e1ed..2a3fda91a 100644 --- a/tests/robustness/options.go +++ b/tests/robustness/options.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/persister.go b/tests/robustness/persister.go index f66382fa7..76fe91b54 100644 --- a/tests/robustness/persister.go +++ b/tests/robustness/persister.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/robustness_test/main_test.go b/tests/robustness/robustness_test/main_test.go index cdea347c2..4c84ba98a 100644 --- a/tests/robustness/robustness_test/main_test.go +++ b/tests/robustness/robustness_test/main_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/robustness_test/robustness_test.go b/tests/robustness/robustness_test/robustness_test.go index c1d2bd340..c0cbe9121 100644 --- a/tests/robustness/robustness_test/robustness_test.go +++ b/tests/robustness/robustness_test/robustness_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package robustness diff --git a/tests/robustness/snapmeta/index.go b/tests/robustness/snapmeta/index.go index a4debcf93..84f59dcba 100644 --- a/tests/robustness/snapmeta/index.go +++ b/tests/robustness/snapmeta/index.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/index_test.go b/tests/robustness/snapmeta/index_test.go index 9805bab9f..c5a242d63 100644 --- a/tests/robustness/snapmeta/index_test.go +++ b/tests/robustness/snapmeta/index_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_connector.go b/tests/robustness/snapmeta/kopia_connector.go index 460786bef..2afa40e61 100644 --- a/tests/robustness/snapmeta/kopia_connector.go +++ b/tests/robustness/snapmeta/kopia_connector.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_connector_test.go b/tests/robustness/snapmeta/kopia_connector_test.go index 84e6b5eba..4815133e2 100644 --- a/tests/robustness/snapmeta/kopia_connector_test.go +++ b/tests/robustness/snapmeta/kopia_connector_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_persister.go b/tests/robustness/snapmeta/kopia_persister.go index 39146cfdc..103b10dd2 100644 --- a/tests/robustness/snapmeta/kopia_persister.go +++ b/tests/robustness/snapmeta/kopia_persister.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package snapmeta provides Kopia implementations of Persister and Snapshotter. package snapmeta diff --git a/tests/robustness/snapmeta/kopia_persister_light.go b/tests/robustness/snapmeta/kopia_persister_light.go index 5db47b2c5..ad97df8a9 100644 --- a/tests/robustness/snapmeta/kopia_persister_light.go +++ b/tests/robustness/snapmeta/kopia_persister_light.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_persister_light_test.go b/tests/robustness/snapmeta/kopia_persister_light_test.go index 5000430a0..509bff065 100644 --- a/tests/robustness/snapmeta/kopia_persister_light_test.go +++ b/tests/robustness/snapmeta/kopia_persister_light_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_snapshotter.go b/tests/robustness/snapmeta/kopia_snapshotter.go index 3f2fec2f8..6d6b48237 100644 --- a/tests/robustness/snapmeta/kopia_snapshotter.go +++ b/tests/robustness/snapmeta/kopia_snapshotter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/kopia_snapshotter_upgrade_test.go b/tests/robustness/snapmeta/kopia_snapshotter_upgrade_test.go index f068a4127..e893f4251 100644 --- a/tests/robustness/snapmeta/kopia_snapshotter_upgrade_test.go +++ b/tests/robustness/snapmeta/kopia_snapshotter_upgrade_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/simple.go b/tests/robustness/snapmeta/simple.go index c6ecbc870..c3c0cac3b 100644 --- a/tests/robustness/snapmeta/simple.go +++ b/tests/robustness/snapmeta/simple.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapmeta/simple_test.go b/tests/robustness/snapmeta/simple_test.go index cd36869cd..5ed2cefcd 100644 --- a/tests/robustness/snapmeta/simple_test.go +++ b/tests/robustness/snapmeta/simple_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package snapmeta diff --git a/tests/robustness/snapshotter.go b/tests/robustness/snapshotter.go index e2df9c26d..74cf3d9fa 100644 --- a/tests/robustness/snapshotter.go +++ b/tests/robustness/snapshotter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package robustness contains tests that validate data stability over time. // The package, while designed for Kopia, is written with abstractions that diff --git a/tests/socketactivation_test/socketactivation_test.go b/tests/socketactivation_test/socketactivation_test.go index 35ba4326b..aace34475 100644 --- a/tests/socketactivation_test/socketactivation_test.go +++ b/tests/socketactivation_test/socketactivation_test.go @@ -1,5 +1,4 @@ //go:build linux -// +build linux package socketactivation_test diff --git a/tests/testdirtree/testdirtree.go b/tests/testdirtree/testdirtree.go index 6d0ba8f23..bf9f9a92e 100644 --- a/tests/testdirtree/testdirtree.go +++ b/tests/testdirtree/testdirtree.go @@ -9,6 +9,7 @@ "math/rand" "os" "path/filepath" + "strings" "sync/atomic" "testing" "unicode" @@ -43,7 +44,7 @@ func generateHexString(l int) string { func generateUnicodeString(rangeMin, rangeMax, l int) string { // generate a random unicode string within a defined range - s := "" + var s strings.Builder for i := 0; i < l; { c := rand.Intn(rangeMax-rangeMin+1) + rangeMin @@ -51,12 +52,13 @@ func generateUnicodeString(rangeMin, rangeMax, l int) string { // IsLetter & IsDigit function as a sanity check to prevent writing punctuation/control characters // ValidRune is a sanity check for macOS since APFS can't handle invalid utf-8 and will error out if (unicode.IsLetter(r) || unicode.IsDigit(r)) && utf8.ValidRune(r) { - s += string(r) + s.WriteRune(r) + i++ } } - return s + return s.String() } func randomUnicodeName(l int) string { diff --git a/tests/tools/fswalker/fswalker.go b/tests/tools/fswalker/fswalker.go index bc1f1cd6c..d618f9cdb 100644 --- a/tests/tools/fswalker/fswalker.go +++ b/tests/tools/fswalker/fswalker.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package fswalker provides the checker.Comparer interface using FSWalker // walker and reporter. diff --git a/tests/tools/fswalker/fswalker_test.go b/tests/tools/fswalker/fswalker_test.go index 39af33430..b279a8018 100644 --- a/tests/tools/fswalker/fswalker_test.go +++ b/tests/tools/fswalker/fswalker_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package fswalker diff --git a/tests/tools/fswalker/reporter/reporter.go b/tests/tools/fswalker/reporter/reporter.go index befaf0364..9f3f4e91b 100644 --- a/tests/tools/fswalker/reporter/reporter.go +++ b/tests/tools/fswalker/reporter/reporter.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package reporter wraps calls to the fswalker Reporter package reporter diff --git a/tests/tools/fswalker/reporter/reporter_test.go b/tests/tools/fswalker/reporter/reporter_test.go index 8319d4d61..459729c8f 100644 --- a/tests/tools/fswalker/reporter/reporter_test.go +++ b/tests/tools/fswalker/reporter/reporter_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package reporter diff --git a/tests/tools/fswalker/walker/walker.go b/tests/tools/fswalker/walker/walker.go index a4d89edc1..ee98fc354 100644 --- a/tests/tools/fswalker/walker/walker.go +++ b/tests/tools/fswalker/walker/walker.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package walker wraps calls to the fswalker Walker package walker diff --git a/tests/tools/fswalker/walker/walker_test.go b/tests/tools/fswalker/walker/walker_test.go index 5ce3dfc5d..6c59a8ad9 100644 --- a/tests/tools/fswalker/walker/walker_test.go +++ b/tests/tools/fswalker/walker/walker_test.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 package walker diff --git a/tests/tools/kopiaclient/kopiaclient.go b/tests/tools/kopiaclient/kopiaclient.go index 184edcf05..26709164e 100644 --- a/tests/tools/kopiaclient/kopiaclient.go +++ b/tests/tools/kopiaclient/kopiaclient.go @@ -1,5 +1,4 @@ //go:build darwin || (linux && amd64) -// +build darwin linux,amd64 // Package kopiaclient provides a client to interact with a Kopia repo. package kopiaclient diff --git a/tests/tools/kopiarunner/setpdeath.go b/tests/tools/kopiarunner/setpdeath.go index 28716e150..d792b5002 100644 --- a/tests/tools/kopiarunner/setpdeath.go +++ b/tests/tools/kopiarunner/setpdeath.go @@ -1,5 +1,4 @@ //go:build !linux -// +build !linux package kopiarunner diff --git a/tools/cli2md/cli2md.go b/tools/cli2md/cli2md.go index eda32e7aa..1f80444d6 100644 --- a/tools/cli2md/cli2md.go +++ b/tools/cli2md/cli2md.go @@ -288,20 +288,26 @@ func generateSubcommandPage(fname string, cmd *kingpin.CmdModel) { `, title, title) - flagSummary := "" - argSummary := "" + var ( + argSummary strings.Builder + flagSummary strings.Builder + ) for _, a := range cmd.Args { if a.Required { - argSummary += " <" + a.Name + ">" + argSummary.WriteString(" <") + argSummary.WriteString(a.Name) + argSummary.WriteRune('>') } else { - argSummary += " [" + a.Name + "]" + argSummary.WriteString(" [") + argSummary.WriteString(a.Name) + argSummary.WriteRune(']') } } for _, fl := range cmd.Flags { if fl.Required { - flagSummary += " \\\n --" + fl.Name + "=..." + flagSummary.WriteString(" \\\n --" + fl.Name + "=...") } } diff --git a/tools/gettool/checksums.txt b/tools/gettool/checksums.txt index 50e763f87..9d5e4d438 100644 --- a/tools/gettool/checksums.txt +++ b/tools/gettool/checksums.txt @@ -7,12 +7,12 @@ https://github.com/git-chglog/git-chglog/releases/download/v0.15.1/git-chglog_0. https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_darwin-universal.tar.gz: 1557f896f34743d241e1aecab588be273dde59692b362a9f4488231a2595b2ae https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_linux-amd64.tar.gz: e04bccfa81df6c727f1c03bc858eb21d6f95123d311cafe245f4485d289123f3 https://github.com/gohugoio/hugo/releases/download/v0.113.0/hugo_extended_0.113.0_windows-amd64.zip: 3eabfbfad1431939058e6f7e76573c6bac1fee92f3a7b1ac5739c555940f0e0e -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-darwin-amd64.tar.gz: a7e684872b00637d642d088dde783c1b871161a92678fcf13d07abe6b5c32e36 -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-darwin-arm64.tar.gz: 0b3cbdc2a2472f60b538ebccb1b2e1ae5d938a051c010591aa68c6efd3706672 -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-linux-amd64.tar.gz: c77313a77e19b06123962c411d9943cc0d092bbec76b956104d18964e274902e -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-linux-arm64.tar.gz: 48693a98a7f4556d1117300aae240d0fe483df8d6f36dfaba56504626101a66e -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-linux-armv6.tar.gz: 647afc10610e4dc6f4d9091dc3ee6ff89d96baf2fab8ef9647217e329a1c332e -https://github.com/golangci/golangci-lint/releases/download/v2.5.0/golangci-lint-2.5.0-windows-amd64.zip: 8d37563c2549e38135eac46e778164d2c5b1e96b9211f2087814d74ca0f358a8 +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-darwin-amd64.tar.gz: aee6e16af4dfa60dd3c4e39536edc905f28369fda3c138090db00c8233cfe450 +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-darwin-arm64.tar.gz: 402e903029391f1b6383cc63c8d0fcd38e879a4dfe3a0aff258a1817d7a296ec +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-linux-amd64.tar.gz: c22e188e46aff9b140588abe6828ba271b600ae82b2d6a4f452196a639c17ec0 +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-linux-arm64.tar.gz: 1c22b899f2dd84f9638e0e0352a319a2867b0bb082c5323ad50d8713b65bb793 +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-linux-armv6.tar.gz: b52331fb224cdc987f8f703120d546a98114c400a453c61a2b51a86d0d669dbe +https://github.com/golangci/golangci-lint/releases/download/v2.6.1/golangci-lint-2.6.1-windows-amd64.zip: b6edeea3d1d52331e98dc6378f710cfe2d752ca1ba09032fe60e62a87a27a25f https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_arm64.tar.gz: 1f95e6561974f4766d8833438b646b06930563ca9867447ea03edb623d876c75 https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Darwin_x86_64.tar.gz: 17ecad881a50e32f033da5a200c8417d37cae70f09e925645452937998aca506 https://github.com/goreleaser/goreleaser/releases/download/v0.176.0/goreleaser_Linux_arm64.tar.gz: 8bf2a9b9e84498bfa239f2fe91b2d555642c87ab9d3f5d37f29e6e97116910a3 diff --git a/tools/tools.mk b/tools/tools.mk index 999d3e42f..cd10a338c 100644 --- a/tools/tools.mk +++ b/tools/tools.mk @@ -104,7 +104,7 @@ retry:= endif # tool versions -GOLANGCI_LINT_VERSION=2.5.0 +GOLANGCI_LINT_VERSION=2.6.1 CHECKLOCKS_VERSION=release-20241104.0 NODE_VERSION=22.15.1 HUGO_VERSION=0.113.0