10000 non-constant format string in call error when running tests with go 1.24 · Issue #1630 · bwmarrin/discordgo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
non-constant format string in call error when running tests with go 1.24 #1630
Open
@skoved

Description

@skoved

I've been doing some packaging of go programs for fedora and while packaging the sources for this library I noticed the go vet printf analyzer complains when running the go test when using go1.24. This is due to a change to the printf analyzer in go1.24.

Here is the test command that produced the output

go test -buildmode pie -compiler gc -ldflags " -X github.com/bwmarrin/discordgo/version=0.27.0 -X github.com/bwmarrin/discordgo/version.tag=v0.27.0 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes  '"
      testing: github.com/bwmarrin/discordgo
github.com/bwmarrin/discordgo
# github.com/bwmarrin/discordgo
# [github.com/bwmarrin/discordgo]
./restapi.go:299:28: non-constant format string in call to (*github.com/bwmarrin/discordgo.Session).log
./restapi_test.go:96:12: non-constant format string in call to (*testing.common).Errorf
./restapi_test.go:109:12: non-constant format string in call to (*testing.common).Errorf
FAIL	github.com/bwmarrin/discordgo [build failed]

link to the full build logs if interested.

It seems that there is improper usage of Sprintf/Errorf style functions (at least according to go vet.

I think an easy solution to restapi.go:299 is adding a format string "%s" to the call to s.log and the issues in restapi_test.go can be solved by switching t.Errorf to t.Error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0