From 24e64fe37225a315c74c00d1f5e4d024168feea6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 5 Jul 2023 05:41:32 +0200 Subject: Replace `interface{}` with `any` (#25686) (#25687) Same perl replacement as https://github.com/go-gitea/gitea/pull/25686 but for 1.20 to ease future backporting. --- cmd/cert.go | 6 +++--- cmd/dump.go | 4 ++-- cmd/manager_logging.go | 6 +++--- cmd/serv.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'cmd') diff --git a/cmd/cert.go b/cmd/cert.go index 816659023c..897c10c899 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -63,7 +63,7 @@ Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`, }, } -func publicKey(priv interface{}) interface{} { +func publicKey(priv any) any { switch k := priv.(type) { case *rsa.PrivateKey: return &k.PublicKey @@ -74,7 +74,7 @@ func publicKey(priv interface{}) interface{} { } } -func pemBlockForKey(priv interface{}) *pem.Block { +func pemBlockForKey(priv any) *pem.Block { switch k := priv.(type) { case *rsa.PrivateKey: return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)} @@ -94,7 +94,7 @@ func runCert(c *cli.Context) error { return err } - var priv interface{} + var priv any var err error switch c.String("ecdsa-curve") { case "": diff --git a/cmd/dump.go b/cmd/dump.go index 0b7c1d32c5..b1aed8aef4 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -161,7 +161,7 @@ It can be used for backup and capture Gitea server image to send to maintainer`, }, } -func fatal(format string, args ...interface{}) { +func fatal(format string, args ...any) { fmt.Fprintf(os.Stderr, format+"\n", args...) log.Fatal(format, args...) } @@ -236,7 +236,7 @@ func runDump(ctx *cli.Context) error { return err } - var iface interface{} + var iface any if fileName == "-" { iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType)) } else { diff --git a/cmd/manager_logging.go b/cmd/manager_logging.go index dd85cc26d8..70d1beb26d 100644 --- a/cmd/manager_logging.go +++ b/cmd/manager_logging.go @@ -178,7 +178,7 @@ func runAddConnLogger(c *cli.Context) error { defer cancel() setup(ctx, c.Bool("debug")) - vals := map[string]interface{}{} + vals := map[string]any{} mode := "conn" vals["net"] = "tcp" if c.IsSet("protocol") { @@ -208,7 +208,7 @@ func runAddFileLogger(c *cli.Context) error { defer cancel() setup(ctx, c.Bool("debug")) - vals := map[string]interface{}{} + vals := map[string]any{} mode := "file" if c.IsSet("filename") { vals["filename"] = c.String("filename") @@ -236,7 +236,7 @@ func runAddFileLogger(c *cli.Context) error { return commonAddLogger(c, mode, vals) } -func commonAddLogger(c *cli.Context, mode string, vals map[string]interface{}) error { +func commonAddLogger(c *cli.Context, mode string, vals map[string]any) error { if len(c.String("level")) > 0 { vals["level"] = log.LevelFromString(c.String("level")).String() } diff --git a/cmd/serv.go b/cmd/serv.go index 79052e58a8..484e3bf404 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -95,7 +95,7 @@ var ( // fail prints message to stdout, it's mainly used for git serv and git hook commands. // The output will be passed to git client and shown to user. -func fail(ctx context.Context, userMessage, logMsgFmt string, args ...interface{}) error { +func fail(ctx context.Context, userMessage, logMsgFmt string, args ...any) error { if userMessage == "" { userMessage = "Internal Server Error (no specific error)" } -- cgit v1.2.3