Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

build: fix gocritic lint issue wrapperfunc

albertony33bff6fe713d
diff --git a/backend/drive/drive.go b/backend/drive/drive.go
index 271b0b046..3feef0ef2 100644
--- a/backend/drive/drive.go
+++ b/backend/drive/drive.go
@@ -2219,7 +2219,7 @@ func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) (
case in <- job:
default:
overflow = append(overflow, job)
- wg.Add(-1)
+ wg.Done()
}
}
diff --git a/backend/ftp/ftp.go b/backend/ftp/ftp.go
index 6c7e7b105..75f6e9cdb 100644
--- a/backend/ftp/ftp.go
+++ b/backend/ftp/ftp.go
@@ -85,7 +85,7 @@ to an encrypted one. Cannot be used in combination with implicit FTPS.`,
Default: false,
}, {
Name: "concurrency",
- Help: strings.Replace(`Maximum number of FTP simultaneous connections, 0 for unlimited.
+ Help: strings.ReplaceAll(`Maximum number of FTP simultaneous connections, 0 for unlimited.
Note that setting this is very likely to cause deadlocks so it should
be used with care.
@@ -99,7 +99,7 @@ maximum of |--checkers| and |--transfers|.
So for |concurrency 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|.
-`, "|", "`", -1),
+`, "|", "`"),
Default: 0,
Advanced: true,
}, {
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index 21309afa3..e47e47db2 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -344,7 +344,7 @@ cost of using more memory.
Advanced: true,
}, {
Name: "connections",
- Help: strings.Replace(`Maximum number of SFTP simultaneous connections, 0 for unlimited.
+ Help: strings.ReplaceAll(`Maximum number of SFTP simultaneous connections, 0 for unlimited.
Note that setting this is very likely to cause deadlocks so it should
be used with care.
@@ -358,7 +358,7 @@ maximum of |--checkers| and |--transfers|.
So for |connections 3| you'd use |--checkers 2 --transfers 2
--check-first| or |--checkers 1 --transfers 1|.
-`, "|", "`", -1),
+`, "|", "`"),
Default: 0,
Advanced: true,
}, {
diff --git a/cmd/bisync/bisync_test.go b/cmd/bisync/bisync_test.go
index 5321eab9a..ba1e313e5 100644
--- a/cmd/bisync/bisync_test.go
+++ b/cmd/bisync/bisync_test.go
@@ -1742,8 +1742,8 @@ func (b *bisyncTest) newReplacer(mangle bool) *strings.Replacer {
b.path2, "{path2/}",
b.replaceHex(b.path1), "{path1/}",
b.replaceHex(b.path2), "{path2/}",
- "//?/" + strings.TrimSuffix(strings.Replace(b.path1, slash, "/", -1), "/"), "{path1}", // fix windows-specific issue
- "//?/" + strings.TrimSuffix(strings.Replace(b.path2, slash, "/", -1), "/"), "{path2}",
+ "//?/" + strings.TrimSuffix(strings.ReplaceAll(b.path1, slash, "/"), "/"), "{path1}", // fix windows-specific issue
+ "//?/" + strings.TrimSuffix(strings.ReplaceAll(b.path2, slash, "/"), "/"), "{path2}",
strings.TrimSuffix(b.path1, slash), "{path1}", // ensure it's still recognized without trailing slash
strings.TrimSuffix(b.path2, slash), "{path2}",
b.workDir, "{workdir}",
diff --git a/cmd/bisync/log.go b/cmd/bisync/log.go
index cd39079a6..0d7f4b2f7 100644
--- a/cmd/bisync/log.go
+++ b/cmd/bisync/log.go
@@ -39,8 +39,8 @@ func (b *bisyncRun) indent(tag, file, msg string) {
tag = Color(terminal.BlueFg, tag)
}
msg = Color(terminal.MagentaFg, msg)
- msg = strings.Replace(msg, "Queue copy to", Color(terminal.GreenFg, "Queue copy to"), -1)
- msg = strings.Replace(msg, "Queue delete", Color(terminal.RedFg, "Queue delete"), -1)
+ msg = strings.ReplaceAll(msg, "Queue copy to", Color(terminal.GreenFg, "Queue copy to"))
+ msg = strings.ReplaceAll(msg, "Queue delete", Color(terminal.RedFg, "Queue delete"))
file = Color(terminal.CyanFg, escapePath(file, false))
logf(nil, "- %-18s%-43s - %s", tag, msg, file)
}
diff --git a/cmd/serve/proxy/proxy.go b/cmd/serve/proxy/proxy.go
index 3ad607d89..08ffa8b53 100644
--- a/cmd/serve/proxy/proxy.go
+++ b/cmd/serve/proxy/proxy.go
@@ -23,7 +23,7 @@ import (
)
// Help contains text describing how to use the proxy
-var Help = strings.Replace(`### Auth Proxy
+var Help = strings.ReplaceAll(`### Auth Proxy
If you supply the parameter |--auth-proxy /path/to/program| then
rclone will use that program to generate backends on the fly which
@@ -104,7 +104,7 @@ before it takes effect.
This can be used to build general purpose proxies to any kind of
backend that rclone supports.
-`, "|", "`", -1)
+`, "|", "`")
// Options is options for creating the proxy
type Options struct {
diff --git a/fs/mount_helper.go b/fs/mount_helper.go
index 5239ff9a5..035b75284 100644
--- a/fs/mount_helper.go
+++ b/fs/mount_helper.go
@@ -100,10 +100,7 @@ func convertMountHelperArgs(origArgs []string) ([]string, error) {
continue
}
- param, value := opt, ""
- if idx := strings.Index(opt, "="); idx != -1 {
- param, value = opt[:idx], opt[idx+1:]
- }
+ param, value, _ := strings.Cut(opt, "=")
// Set environment variables
if strings.HasPrefix(param, "env.") {
diff --git a/fs/operations/operations.go b/fs/operations/operations.go
index adeba8d59..92b64f359 100644
--- a/fs/operations/operations.go
+++ b/fs/operations/operations.go
@@ -1807,7 +1807,7 @@ func copyURLFn(ctx context.Context, dstFileName string, url string, autoFilename
if autoFilename {
if dstFileNameFromHeader {
_, params, err := mime.ParseMediaType(resp.Header.Get("Content-Disposition"))
- headerFilename := path.Base(strings.Replace(params["filename"], "\\", "/", -1))
+ headerFilename := path.Base(strings.ReplaceAll(params["filename"], "\\", "/"))
if err != nil || headerFilename == "" {
return fmt.Errorf("CopyURL failed: filename not found in the Content-Disposition header")
}
diff --git a/lib/daemonize/daemon_unix.go b/lib/daemonize/daemon_unix.go
index 6e1e0442e..79fb96b2b 100644
--- a/lib/daemonize/daemon_unix.go
+++ b/lib/daemonize/daemon_unix.go
@@ -87,9 +87,10 @@ func argsToEnv(origArgs, origEnv []string) (args, env []string) {
}
arg = arg[2:]
- key, val := arg, "true"
- if idx := strings.Index(arg, "="); idx != -1 {
- key, val = arg[:idx], arg[idx+1:]
+ var key, val string
+ var ok bool
+ if key, val, ok = strings.Cut(arg, "="); !ok {
+ val = "true"
}
name := "RCLONE_" + strings.ToUpper(strings.ReplaceAll(key, "-", "_"))