From a57ce15d71860a7fe5a4917e84959358c16b09c9 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 29 Jan 2025 15:19:42 +0000 Subject: [PATCH] fix: conform to stricter printf usage in Go 1.24 --- agent/agent_test.go | 2 +- cli/gitssh.go | 2 +- cli/login.go | 2 +- cli/logout.go | 2 +- cli/publickey.go | 10 +++++----- cli/server.go | 2 +- cli/templateversionarchive.go | 4 ++-- coderd/healthcheck/workspaceproxy.go | 4 ++-- coderd/httpapi/httpapi_test.go | 4 ++-- enterprise/cli/proxyserver.go | 2 +- provisioner/terraform/provision.go | 7 +++---- pty/ptytest/ptytest.go | 1 + vpn/tunnel.go | 2 +- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/agent/agent_test.go b/agent/agent_test.go index 37bec33730a10..cfc5ebb4192f0 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -977,7 +977,7 @@ func TestAgent_FileTransferBlocked(t *testing.T) { isErr := strings.Contains(errorMessage, agentssh.BlockedFileTransferErrorMessage) || strings.Contains(errorMessage, "EOF") || strings.Contains(errorMessage, "Process exited with status 65") - require.True(t, isErr, fmt.Sprintf("Message: "+errorMessage)) + require.True(t, isErr, "Message: "+errorMessage) } t.Run("SFTP", func(t *testing.T) { diff --git a/cli/gitssh.go b/cli/gitssh.go index f427e43812841..4a83ace678a3b 100644 --- a/cli/gitssh.go +++ b/cli/gitssh.go @@ -91,7 +91,7 @@ func (r *RootCmd) gitssh() *serpent.Command { if xerrors.As(err, &exitErr) && exitErr.ExitCode() == 255 { _, _ = fmt.Fprintln(inv.Stderr, "\n"+pretty.Sprintf( - cliui.DefaultStyles.Wrap, + cliui.DefaultStyles.Wrap, "%s", "Coder authenticates with "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+ " using the public key below. All clones with SSH are authenticated automatically ๐Ÿช„.")+"\n", ) diff --git a/cli/login.go b/cli/login.go index 591cf66e62418..e7a1d0eb8eb13 100644 --- a/cli/login.go +++ b/cli/login.go @@ -209,7 +209,7 @@ func (r *RootCmd) login() *serpent.Command { // nolint: nestif if !hasFirstUser { - _, _ = fmt.Fprintf(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n") + _, _ = fmt.Fprint(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n") if username == "" { if !isTTYIn(inv) { diff --git a/cli/logout.go b/cli/logout.go index 290422f492f49..6540003650919 100644 --- a/cli/logout.go +++ b/cli/logout.go @@ -68,7 +68,7 @@ func (r *RootCmd) logout() *serpent.Command { errorString := strings.TrimRight(errorStringBuilder.String(), "\n") return xerrors.New("Failed to log out.\n" + errorString) } - _, _ = fmt.Fprintf(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login '.\n") + _, _ = fmt.Fprint(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login '.\n") return nil }, } diff --git a/cli/publickey.go b/cli/publickey.go index 03f17a4bc4952..320ed86b2c697 100644 --- a/cli/publickey.go +++ b/cli/publickey.go @@ -45,14 +45,14 @@ func (r *RootCmd) publickey() *serpent.Command { return xerrors.Errorf("create codersdk client: %w", err) } - cliui.Infof(inv.Stdout, + cliui.Info(inv.Stdout, "This is your public key for using "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+" in "+ "Coder. All clones with SSH will be authenticated automatically ๐Ÿช„.", ) - cliui.Infof(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n") - cliui.Infof(inv.Stdout, "Add to GitHub and GitLab:") - cliui.Infof(inv.Stdout, "> https://github.com/settings/ssh/new") - cliui.Infof(inv.Stdout, "> https://gitlab.com/-/profile/keys") + cliui.Info(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n") + cliui.Info(inv.Stdout, "Add to GitHub and GitLab:") + cliui.Info(inv.Stdout, "> https://github.com/settings/ssh/new") + cliui.Info(inv.Stdout, "> https://gitlab.com/-/profile/keys") return nil }, diff --git a/cli/server.go b/cli/server.go index 48f049c163b3b..03dcc698c1f05 100644 --- a/cli/server.go +++ b/cli/server.go @@ -513,7 +513,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. } accessURL := vals.AccessURL.String() - cliui.Infof(inv.Stdout, lipgloss.NewStyle(). + cliui.Info(inv.Stdout, lipgloss.NewStyle(). Border(lipgloss.DoubleBorder()). Align(lipgloss.Center). Padding(0, 3). diff --git a/cli/templateversionarchive.go b/cli/templateversionarchive.go index 10beda42b9afa..e9b41ff31dcd1 100644 --- a/cli/templateversionarchive.go +++ b/cli/templateversionarchive.go @@ -76,7 +76,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command { for _, version := range versions { if version.Archived == archive { _, _ = fmt.Fprintln( - inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb), + inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb, ) continue } @@ -87,7 +87,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command { } _, _ = fmt.Fprintln( - inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now())), + inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now()), ) } return nil diff --git a/coderd/healthcheck/workspaceproxy.go b/coderd/healthcheck/workspaceproxy.go index d9fdfd5295d6f..65a3b439553b9 100644 --- a/coderd/healthcheck/workspaceproxy.go +++ b/coderd/healthcheck/workspaceproxy.go @@ -100,9 +100,9 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo for _, err := range errs { switch r.Severity { case health.SeverityWarning, health.SeverityOK: - r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, err)) + r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, "%s", err)) case health.SeverityError: - r.appendError(*health.Errorf(health.CodeProxyUnhealthy, err)) + r.appendError(*health.Errorf(health.CodeProxyUnhealthy, "%s", err)) } } } diff --git a/coderd/httpapi/httpapi_test.go b/coderd/httpapi/httpapi_test.go index 635ed2bdc1e29..eb3f23e6ca346 100644 --- a/coderd/httpapi/httpapi_test.go +++ b/coderd/httpapi/httpapi_test.go @@ -143,7 +143,7 @@ func TestWebsocketCloseMsg(t *testing.T) { t.Parallel() msg := strings.Repeat("d", 255) - trunc := httpapi.WebsocketCloseSprintf(msg) + trunc := httpapi.WebsocketCloseSprintf("%s", msg) assert.Equal(t, len(trunc), 123) }) @@ -151,7 +151,7 @@ func TestWebsocketCloseMsg(t *testing.T) { t.Parallel() msg := strings.Repeat("ใ“ใ‚“ใซใกใฏ", 10) - trunc := httpapi.WebsocketCloseSprintf(msg) + trunc := httpapi.WebsocketCloseSprintf("%s", msg) assert.Equal(t, len(trunc), 123) }) } diff --git a/enterprise/cli/proxyserver.go b/enterprise/cli/proxyserver.go index 9e10048146481..a4a989ae0460f 100644 --- a/enterprise/cli/proxyserver.go +++ b/enterprise/cli/proxyserver.go @@ -205,7 +205,7 @@ func (r *RootCmd) proxyServer() *serpent.Command { httpClient.Transport = headerTransport accessURL := cfg.AccessURL.String() - cliui.Infof(inv.Stdout, lipgloss.NewStyle(). + cliui.Info(inv.Stdout, lipgloss.NewStyle(). Border(lipgloss.DoubleBorder()). Align(lipgloss.Center). Padding(0, 3). diff --git a/provisioner/terraform/provision.go b/provisioner/terraform/provision.go index 70a83bb2334b2..3025e5de36469 100644 --- a/provisioner/terraform/provision.go +++ b/provisioner/terraform/provision.go @@ -78,7 +78,7 @@ func (s *server) Plan( e := s.executor(sess.WorkDirectory, database.ProvisionerJobTimingStagePlan) if err := e.checkMinVersion(ctx); err != nil { - return provisionersdk.PlanErrorf(err.Error()) + return provisionersdk.PlanErrorf("%s", err.Error()) } logTerraformEnvVars(sess) @@ -113,7 +113,6 @@ func (s *server) Plan( initTimings.ingest(createInitTimingsEvent(timingInitStart)) err = e.init(ctx, killCtx, sess) - if err != nil { initTimings.ingest(createInitTimingsEvent(timingInitErrored)) @@ -168,7 +167,7 @@ func (s *server) Plan( request.Metadata.GetWorkspaceTransition() == proto.WorkspaceTransition_DESTROY, ) if err != nil { - return provisionersdk.PlanErrorf(err.Error()) + return provisionersdk.PlanErrorf("%s", err.Error()) } // Prepend init timings since they occur prior to plan timings. @@ -189,7 +188,7 @@ func (s *server) Apply( e := s.executor(sess.WorkDirectory, database.ProvisionerJobTimingStageApply) if err := e.checkMinVersion(ctx); err != nil { - return provisionersdk.ApplyErrorf(err.Error()) + return provisionersdk.ApplyErrorf("%s", err.Error()) } logTerraformEnvVars(sess) diff --git a/pty/ptytest/ptytest.go b/pty/ptytest/ptytest.go index 1f0493dfa1a13..a871a0ddcafa0 100644 --- a/pty/ptytest/ptytest.go +++ b/pty/ptytest/ptytest.go @@ -252,6 +252,7 @@ func (e *outExpecter) Peek(ctx context.Context, n int) []byte { return slices.Clone(out) } +//nolint:govet // We don't care about conforming to ReadRune() (rune, int, error). func (e *outExpecter) ReadRune(ctx context.Context) rune { e.t.Helper() diff --git a/vpn/tunnel.go b/vpn/tunnel.go index d9f2877ebbc9d..b33dd5b0847de 100644 --- a/vpn/tunnel.go +++ b/vpn/tunnel.go @@ -71,7 +71,7 @@ func NewTunnel( return nil, err } t := &Tunnel{ - // nolint: govet // safe to copy the locks here because we haven't started the speaker + //nolint:govet // safe to copy the locks here because we haven't started the speaker speaker: *(s), ctx: ctx, logger: logger, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy