From 706846b62847228824b62ecdedc76637eaf995cf Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 12 Apr 2024 13:36:31 +0200 Subject: [PATCH] [CHORE] Remove `println` - It's not recommended to use it per the documentation: https://pkg.go.dev/builtin#println. --- build/backport-locales.go | 4 ++-- cmd/serv.go | 10 +++++----- modules/git/diff_test.go | 16 ---------------- tests/e2e/debugserver_test.go | 3 ++- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/build/backport-locales.go b/build/backport-locales.go index d112dd72bd..3df83ea6d9 100644 --- a/build/backport-locales.go +++ b/build/backport-locales.go @@ -18,8 +18,8 @@ import ( func main() { if len(os.Args) != 2 { - println("usage: backport-locales ") - println("eg: backport-locales release/v1.19") + fmt.Println("usage: backport-locales ") + fmt.Println("eg: backport-locales release/v1.19") os.Exit(1) } diff --git a/cmd/serv.go b/cmd/serv.go index d5c54f91b8..0e3006b36b 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -136,7 +136,7 @@ func runServ(c *cli.Context) error { setup(ctx, c.Bool("debug")) if setting.SSH.Disabled { - println("Forgejo: SSH has been disabled") + fmt.Println("Forgejo: SSH has been disabled") return nil } @@ -164,13 +164,13 @@ func runServ(c *cli.Context) error { } switch key.Type { case asymkey_model.KeyTypeDeploy: - println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Forgejo does not provide shell access.") + fmt.Println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Forgejo does not provide shell access.") case asymkey_model.KeyTypePrincipal: - println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Forgejo does not provide shell access.") + fmt.Println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Forgejo does not provide shell access.") default: - println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Forgejo does not provide shell access.") + fmt.Println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Forgejo does not provide shell access.") } - println("If this is unexpected, please log in with password and setup Forgejo under another user.") + fmt.Println("If this is unexpected, please log in with password and setup Forgejo under another user.") return nil } else if c.Bool("debug") { log.Debug("SSH_ORIGINAL_COMMAND: %s", os.Getenv("SSH_ORIGINAL_COMMAND")) diff --git a/modules/git/diff_test.go b/modules/git/diff_test.go index 0f865c52a8..8fa47a943c 100644 --- a/modules/git/diff_test.go +++ b/modules/git/diff_test.go @@ -159,22 +159,6 @@ func BenchmarkCutDiffAroundLine(b *testing.B) { } } -func ExampleCutDiffAroundLine() { - const diff = `diff --git a/README.md b/README.md ---- a/README.md -+++ b/README.md -@@ -1,3 +1,6 @@ - # gitea-github-migrator -+ -+ Build Status -- Latest Release - Docker Pulls -+ cut off -+ cut off` - result, _ := CutDiffAroundLine(strings.NewReader(diff), 4, false, 3) - println(result) -} - func TestParseDiffHunkString(t *testing.T) { leftLine, leftHunk, rightLine, rightHunk := ParseDiffHunkString("@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER") assert.EqualValues(t, 19, leftLine) diff --git a/tests/e2e/debugserver_test.go b/tests/e2e/debugserver_test.go index f0f54665e1..b1496b22a1 100644 --- a/tests/e2e/debugserver_test.go +++ b/tests/e2e/debugserver_test.go @@ -10,6 +10,7 @@ package e2e import ( + "fmt" "net/url" "os" "os/signal" @@ -24,7 +25,7 @@ func TestDebugserver(t *testing.T) { signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) onGiteaRun(t, func(*testing.T, *url.URL) { - println(setting.AppURL) + fmt.Println(setting.AppURL) <-done }) }