Skip to content

Commit 9520da3

Browse files
authored
fix: conform to stricter printf usage in Go 1.24 (#16330)
1 parent 967a381 commit 9520da3

File tree

13 files changed

+22
-22
lines changed

13 files changed

+22
-22
lines changed

agent/agent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ func TestAgent_FileTransferBlocked(t *testing.T) {
977977
isErr := strings.Contains(errorMessage, agentssh.BlockedFileTransferErrorMessage) ||
978978
strings.Contains(errorMessage, "EOF") ||
979979
strings.Contains(errorMessage, "Process exited with status 65")
980-
require.True(t, isErr, fmt.Sprintf("Message: "+errorMessage))
980+
require.True(t, isErr, "Message: "+errorMessage)
981981
}
982982

983983
t.Run("SFTP", func(t *testing.T) {

cli/gitssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (r *RootCmd) gitssh() *serpent.Command {
9191
if xerrors.As(err, &exitErr) && exitErr.ExitCode() == 255 {
9292
_, _ = fmt.Fprintln(inv.Stderr,
9393
"\n"+pretty.Sprintf(
94-
cliui.DefaultStyles.Wrap,
94+
cliui.DefaultStyles.Wrap, "%s",
9595
"Coder authenticates with "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+
9696
" using the public key below. All clones with SSH are authenticated automatically 🪄.")+"\n",
9797
)

cli/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (r *RootCmd) login() *serpent.Command {
209209

210210
// nolint: nestif
211211
if !hasFirstUser {
212-
_, _ = fmt.Fprintf(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
212+
_, _ = fmt.Fprint(inv.Stdout, Caret+"Your Coder deployment hasn't been set up!\n")
213213

214214
if username == "" {
215215
if !isTTYIn(inv) {

cli/logout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (r *RootCmd) logout() *serpent.Command {
6868
errorString := strings.TrimRight(errorStringBuilder.String(), "\n")
6969
return xerrors.New("Failed to log out.\n" + errorString)
7070
}
71-
_, _ = fmt.Fprintf(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
71+
_, _ = fmt.Fprint(inv.Stdout, Caret+"You are no longer logged in. You can log in using 'coder login <url>'.\n")
7272
return nil
7373
},
7474
}

cli/publickey.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func (r *RootCmd) publickey() *serpent.Command {
4545
return xerrors.Errorf("create codersdk client: %w", err)
4646
}
4747

48-
cliui.Infof(inv.Stdout,
48+
cliui.Info(inv.Stdout,
4949
"This is your public key for using "+pretty.Sprint(cliui.DefaultStyles.Field, "git")+" in "+
5050
"Coder. All clones with SSH will be authenticated automatically 🪄.",
5151
)
52-
cliui.Infof(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
53-
cliui.Infof(inv.Stdout, "Add to GitHub and GitLab:")
54-
cliui.Infof(inv.Stdout, "> https://github.com/settings/ssh/new")
55-
cliui.Infof(inv.Stdout, "> https://gitlab.com/-/profile/keys")
52+
cliui.Info(inv.Stdout, pretty.Sprint(cliui.DefaultStyles.Code, strings.TrimSpace(key.PublicKey))+"\n")
53+
cliui.Info(inv.Stdout, "Add to GitHub and GitLab:")
54+
cliui.Info(inv.Stdout, "> https://github.com/settings/ssh/new")
55+
cliui.Info(inv.Stdout, "> https://gitlab.com/-/profile/keys")
5656

5757
return nil
5858
},

cli/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
513513
}
514514

515515
accessURL := vals.AccessURL.String()
516-
cliui.Infof(inv.Stdout, lipgloss.NewStyle().
516+
cliui.Info(inv.Stdout, lipgloss.NewStyle().
517517
Border(lipgloss.DoubleBorder()).
518518
Align(lipgloss.Center).
519519
Padding(0, 3).

cli/templateversionarchive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
7676
for _, version := range versions {
7777
if version.Archived == archive {
7878
_, _ = fmt.Fprintln(
79-
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb),
79+
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" already "+pastVerb,
8080
)
8181
continue
8282
}
@@ -87,7 +87,7 @@ func (r *RootCmd) setArchiveTemplateVersion(archive bool) *serpent.Command {
8787
}
8888

8989
_, _ = fmt.Fprintln(
90-
inv.Stdout, fmt.Sprintf("Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now())),
90+
inv.Stdout, "Version "+pretty.Sprint(cliui.DefaultStyles.Keyword, version.Name)+" "+pastVerb+" at "+cliui.Timestamp(time.Now()),
9191
)
9292
}
9393
return nil

coderd/healthcheck/workspaceproxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
100100
for _, err := range errs {
101101
switch r.Severity {
102102
case health.SeverityWarning, health.SeverityOK:
103-
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, err))
103+
r.Warnings = append(r.Warnings, health.Messagef(health.CodeProxyUnhealthy, "%s", err))
104104
case health.SeverityError:
105-
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, err))
105+
r.appendError(*health.Errorf(health.CodeProxyUnhealthy, "%s", err))
106106
}
107107
}
108108
}

coderd/httpapi/httpapi_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ func TestWebsocketCloseMsg(t *testing.T) {
143143
t.Parallel()
144144

145145
msg := strings.Repeat("d", 255)
146-
trunc := httpapi.WebsocketCloseSprintf(msg)
146+
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
147147
assert.Equal(t, len(trunc), 123)
148148
})
149149

150150
t.Run("TruncateMultiByteCharacters", func(t *testing.T) {
151151
t.Parallel()
152152

153153
msg := strings.Repeat("こんにちは", 10)
154-
trunc := httpapi.WebsocketCloseSprintf(msg)
154+
trunc := httpapi.WebsocketCloseSprintf("%s", msg)
155155
assert.Equal(t, len(trunc), 123)
156156
})
157157
}

enterprise/cli/proxyserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func (r *RootCmd) proxyServer() *serpent.Command {
205205
httpClient.Transport = headerTransport
206206

207207
accessURL := cfg.AccessURL.String()
208-
cliui.Infof(inv.Stdout, lipgloss.NewStyle().
208+
cliui.Info(inv.Stdout, lipgloss.NewStyle().
209209
Border(lipgloss.DoubleBorder()).
210210
Align(lipgloss.Center).
211211
Padding(0, 3).

0 commit comments

Comments
 (0)
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