Skip to content

x/website/_content/doc/tutorial: go vet flags tutorial code for non-constant format string #73845

Closed
@FelixDobler

Description

@FelixDobler

What is the URL of the page with the issue?

https://go.dev/doc/tutorial/add-a-test

What is your user agent?

Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0

Screenshot

Image

What did you do?

Follow the steps in the tutorial.

What did you expect to see?

I expected to see the same command output for go test in the tutorial as on my local machine when executing the command.

What did you see instead?

For step 5, the outputs don't match. It seems like go now does advanced code checking and already detects a static issue without running the actual test.

Tutorial Output

$ go test
--- FAIL: TestHelloName (0.00s)
    greetings_test.go:15: Hello("Gladys") = "Hail, %v! Well met!", <nil>, want match for `\bGladys\b`, nil
FAIL
exit status 1
FAIL    example.com/greetings   0.182s

Local Output

using go version go1.24.2 windows/amd64

$ go test
# exammple.com/greetings
# [exammple.com/greetings]
.\greetings.go:20:25: non-constant format string in call to fmt.Sprintf
FAIL    exammple.com/greetings [build failed]

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.website

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions