aboutsummaryrefslogtreecommitdiff
path: root/internal/route
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2022-03-06 16:33:55 +0800
committerGitHub <noreply@github.com>2022-03-06 16:33:55 +0800
commit5afca6ca8eaadebc613dce291da2bae1030ccca9 (patch)
tree46f86403c6abdeabd6172ee5243caa3bfe5a79a4 /internal/route
parentdeec3516d53e9a9679128ade0556ccc818a67be1 (diff)
autofix: function call can be replaced with helper function (#6805)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Diffstat (limited to 'internal/route')
-rw-r--r--internal/route/install.go4
-rw-r--r--internal/route/repo/editor.go2
-rw-r--r--internal/route/repo/view.go2
3 files changed, 4 insertions, 4 deletions
diff --git a/internal/route/install.go b/internal/route/install.go
index 94c7dd2c..4a529655 100644
--- a/internal/route/install.go
+++ b/internal/route/install.go
@@ -240,7 +240,7 @@ func InstallPost(c *context.Context, f form.Install) {
}
// Test repository root path.
- f.RepoRootPath = strings.Replace(f.RepoRootPath, "\\", "/", -1)
+ f.RepoRootPath = strings.ReplaceAll(f.RepoRootPath, "\\", "/")
if err := os.MkdirAll(f.RepoRootPath, os.ModePerm); err != nil {
c.FormErr("RepoRootPath")
c.RenderWithErr(c.Tr("install.invalid_repo_path", err), INSTALL, &f)
@@ -248,7 +248,7 @@ func InstallPost(c *context.Context, f form.Install) {
}
// Test log root path.
- f.LogRootPath = strings.Replace(f.LogRootPath, "\\", "/", -1)
+ f.LogRootPath = strings.ReplaceAll(f.LogRootPath, "\\", "/")
if err := os.MkdirAll(f.LogRootPath, os.ModePerm); err != nil {
c.FormErr("LogRootPath")
c.RenderWithErr(c.Tr("install.invalid_log_root_path", err), INSTALL, &f)
diff --git a/internal/route/repo/editor.go b/internal/route/repo/editor.go
index 8f612a98..58536f5b 100644
--- a/internal/route/repo/editor.go
+++ b/internal/route/repo/editor.go
@@ -268,7 +268,7 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
OldTreeName: oldTreePath,
NewTreeName: f.TreePath,
Message: message,
- Content: strings.Replace(f.Content, "\r", "", -1),
+ Content: strings.ReplaceAll(f.Content, "\r", ""),
IsNewFile: isNewFile,
}); err != nil {
log.Error("Failed to update repo file: %v", err)
diff --git a/internal/route/repo/view.go b/internal/route/repo/view.go
index e9f340cb..89d6f86d 100644
--- a/internal/route/repo/view.go
+++ b/internal/route/repo/view.go
@@ -95,7 +95,7 @@ func renderDirectory(c *context.Context, treeLink string) {
c.Data["IsIPythonNotebook"] = true
c.Data["RawFileLink"] = c.Repo.RepoLink + "/raw/" + path.Join(c.Repo.BranchName, c.Repo.TreePath, readmeFile.Name())
default:
- p = bytes.Replace(p, []byte("\n"), []byte(`<br>`), -1)
+ p = bytes.ReplaceAll(p, []byte("\n"), []byte(`<br>`))
}
c.Data["FileContent"] = string(p)
}