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?
- Follow the "Create a Go Module" tutorial from the beginning to Step 6: Add a test.
- In Step 4 ("Break the greetings.Hello function to view a failing test."), make the breaking change.
- 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 https://github.com/golang/go/issues/60529, which landed in 1.24 (I am using 1.24.5).