Skip to content

fix: conform to stricter printf usage in Go 1.24 #16330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jan 29, 2025

This are being auto-fixed by VS Code so I decided to fix them all:

With Go 1.24rc2:

❯ go vet ./...
# github.com/coder/coder/v2/pty/ptytest
# [github.com/coder/coder/v2/pty/ptytest]
pty/ptytest/ptytest.go:255:23: method ReadRune(ctx context.Context) rune should have signature ReadRune() (rune, int, error)
# github.com/coder/coder/v2/coderd/httpapi_test
# [github.com/coder/coder/v2/coderd/httpapi_test]
coderd/httpapi/httpapi_test.go:146:42: non-constant format string in call to github.com/coder/coder/v2/coderd/httpapi.WebsocketCloseSprintf
coderd/httpapi/httpapi_test.go:154:42: non-constant format string in call to github.com/coder/coder/v2/coderd/httpapi.WebsocketCloseSprintf
# github.com/coder/coder/v2/vpn
# [github.com/coder/coder/v2/vpn]
vpn/tunnel.go:75:20: literal copies lock value from *(s): github.com/coder/coder/v2/vpn.speaker[*github.com/coder/coder/v2/vpn.TunnelMessage, *github.com/coder/coder/v2/vpn.ManagerMessage, github.com/coder/coder/v2/vpn.ManagerMessage] contains sync.Mutex
# github.com/coder/coder/v2/provisioner/terraform
# [github.com/coder/coder/v2/provisioner/terraform]
provisioner/terraform/provision.go:81:36: non-constant format string in call to github.com/coder/coder/v2/provisionersdk.PlanErrorf
provisioner/terraform/provision.go:171:36: non-constant format string in call to github.com/coder/coder/v2/provisionersdk.PlanErrorf
provisioner/terraform/provision.go:192:37: non-constant format string in call to github.com/coder/coder/v2/provisionersdk.ApplyErrorf
# github.com/coder/coder/v2/coderd/healthcheck
# [github.com/coder/coder/v2/coderd/healthcheck]
coderd/healthcheck/workspaceproxy.go:103:79: non-constant format string in call to github.com/coder/coder/v2/coderd/healthcheck/health.Messagef
coderd/healthcheck/workspaceproxy.go:105:60: non-constant format string in call to github.com/coder/coder/v2/coderd/healthcheck/health.Errorf
# github.com/coder/coder/v2/agent_test
# [github.com/coder/coder/v2/agent_test]
agent/agent_test.go:980:38: non-constant format string in call to fmt.Sprintf
# github.com/coder/coder/v2/cli
# [github.com/coder/coder/v2/cli]
cli/gitssh.go:95:8: non-constant format string in call to github.com/coder/pretty.Sprintf
cli/login.go:212:36: non-constant format string in call to fmt.Fprintf
cli/logout.go:71:35: non-constant format string in call to fmt.Fprintf
cli/publickey.go:49:5: non-constant format string in call to github.com/coder/coder/v2/cli/cliui.Infof
cli/publickey.go:52:28: non-constant format string in call to github.com/coder/coder/v2/cli/cliui.Infof
cli/server.go:516:28: non-constant format string in call to github.com/coder/coder/v2/cli/cliui.Infof
cli/templateversionarchive.go:79:31: non-constant format string in call to fmt.Sprintf
cli/templateversionarchive.go:90:30: non-constant format string in call to fmt.Sprintf
# github.com/coder/coder/v2/enterprise/cli
# [github.com/coder/coder/v2/enterprise/cli]
enterprise/cli/proxyserver.go:208:28: non-constant format string in call to github.com/coder/coder/v2/cli/cliui.Infof

After:

# github.com/coder/coder/v2/pty/ptytest
# [github.com/coder/coder/v2/pty/ptytest]
pty/ptytest/ptytest.go:256:23: method ReadRune(ctx context.Context) rune should have signature ReadRune() (rune, int, error)
# github.com/coder/coder/v2/vpn
# [github.com/coder/coder/v2/vpn]
vpn/tunnel.go:75:20: literal copies lock value from *(s): github.com/coder/coder/v2/vpn.speaker[*github.com/coder/coder/v2/vpn.TunnelMessage, *github.com/coder/coder/v2/vpn.ManagerMessage, github.com/coder/coder/v2/vpn.ManagerMessage] contains sync.Mutex

These have nolints but the go vet command doesn't care about them.

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks 👍

@@ -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())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG this is cursed.

@mafredri mafredri merged commit 9520da3 into main Jan 29, 2025
37 checks passed
@mafredri mafredri deleted the mafredri/fix-conform-to-go1-24-vet branch January 29, 2025 16:06
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants