Skip to content

x/website: "Create a Go module" tutorial "Add a test" instructions broken by recent change to vetting printf calls #75131

@garrettr

Description

@garrettr

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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36

Screenshot

This is an issue with the result of running the tutorial code locally, not with the tutorial page itself, so a screenshot wouldn't be useful here.

What did you do?

  1. Follow the "Create a Go Module" tutorial from the beginning to Step 6: Add a test.
  2. In Step 4 ("Break the greetings.Hello function to view a failing test."), make the breaking change.
  3. Perform Step 5 (run go test)

To make this easier for you to reproduce, I am attaching a .zip containing the code up to this point in the tutorial that is reproducing the issue on my machine: create-a-go-module.zip.

What did you expect to see?

The test failure described in Step 5:

$ 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

What did you see instead?

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

I think the tutorial's recommended breaking change is now blocked by go vet from #60529, which landed in 1.24 (I am using 1.24.5).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions