{"record":{"id":"0a7be151f1ec8f6e","repo":"golang/go","slug":"s-wrong-signature-for-s-s","errorCode":null,"errorMessage":"%s: wrong signature for %s, %s","messagePattern":"(.+?): wrong signature for (.+?), (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/test.go","lineNumber":815,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tt.Examples = append(t.Examples, testFunc{pkg, \"Example\" + e.Name, e.Output, e.Unordered})\n\t\t*seen = true\n\t}\n\treturn nil\n}\n\nfunc checkTestFunc(fn *ast.FuncDecl, arg string) error {\n\tvar why string\n\tif !isTestFunc(fn, arg) {\n\t\twhy = fmt.Sprintf(\"must be: func %s(%s *testing.%s)\", fn.Name.String(), strings.ToLower(arg), arg)\n\t}\n\tif fn.Type.TypeParams.NumFields() > 0 {\n\t\twhy = \"test functions cannot have type parameters\"\n\t}\n\tif why != \"\" {\n\t\tpos := testFileSet.Position(fn.Pos())\n\t\treturn fmt.Errorf(\"%s: wrong signature for %s, %s\", pos, fn.Name.String(), why)\n\t}\n\treturn nil\n}\n\nvar testmainTmpl = lazytemplate.New(\"main\", `\n// Code generated by 'go test'. DO NOT EDIT.\n\npackage main\n\nimport (\n\t\"os\"\n{{if .TestMain}}\n\t\"reflect\"\n{{end}}\n\t\"testing\"\n\t\"testing/internal/testdeps\"\n{{if .Cover}}\n\t\"internal/coverage/cfile\"","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/test.go#L797-L833","documentation":"From `checkTestFunc`: a function named like a test entry point (TestXxx, BenchmarkXxx, ExampleXxx, FuzzXxx, TestMain) does not match the required signature, or carries type parameters (forbidden on test functions). The message states the expected form, e.g. `must be: func TestFoo(t *testing.T)`.","triggerScenarios":"Writing `func TestFoo()` (missing parameter), `func TestFoo(t testing.T)` (value not pointer), `func BenchmarkFoo(b *testing.B)` with wrong type, or `func TestFoo[T any](t *testing.T)` (type parameters not allowed on test functions).","commonSituations":"Forgetting the `*testing.T`/`*testing.B` parameter, copy-paste from non-test code with value receivers, attempting to parameterize tests with generics.","solutions":["Match the exact signature: `func TestXxx(t *testing.T)`, `func BenchmarkXxx(b *testing.B)`, `func ExampleXxx()`, `func FuzzXxx(f *testing.F)`, `func TestMain(m *testing.M)`.","Remove any type parameter clause `[T any]` from test functions.","Run `go vet` on the package — it flags malformed test functions before `go test`."],"exampleFix":"// before\nfunc TestSum(t testing.T) { ... }\n\n// after\nfunc TestSum(t *testing.T) { ... }","handlingStrategy":"validation","validationCode":"// Run go vet on the test package before go test.\nfunc vetTestPkg(dir string) error {\n    return exec.Command(\"go\", \"vet\", dir).Run()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `go vet` as a CI gate; it catches malformed test signatures before `go test`.","Keep the canonical signatures next to your editor snippets.","Never add type parameters to test functions."],"tags":["go-toolchain","testing","signature","vet"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}