{"record":{"id":"055edd0dbf6fbeae","repo":"inancgumus/learngo","slug":"signature-doesn-t-match-got-x-want-x-055edd","errorCode":null,"errorMessage":"signature doesn't match, got: % x, want: % x","messagePattern":"signature doesn't match, got: % x, want: % x","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"interfaces/18-testing/reader.go","lineNumber":36,"sourceCode":"// Read implements the io.Reader interface.\nfunc (sr *signatureReader) Read(b []byte) (n int, err error) {\n\tn, err = sr.r.Read(b)\n\n\tl := len(sr.signature)\n\tif l == 0 {\n\t\treturn\n\t}\n\tif lb := len(b); lb < l {\n\t\tl = lb\n\t}\n\tif got, want := b[:l], sr.signature[:l]; !bytes.Equal(got, want) {\n\t\terr = fmt.Errorf(\"signature doesn't match, got: % x, want: % x\", got, want)\n\t}\n\tsr.signature = nil\n\treturn\n}","sourceCodeStart":18,"sourceCodeEnd":49,"githubUrl":"https://github.com/inancgumus/learngo/blob/3c475a78e54336c6255e925ff66b8ef4da6a2ae7/interfaces/18-testing/reader.go#L18-L49","documentation":"signatureReader.Read (testing variant) checks the initial bytes from the wrapped reader against sr.signature and, if they differ, replaces the read error with this formatted mismatch error containing hex dumps of got and want. It fires when a stream expected to start with a specific magic-number prefix (e.g. an image header) starts with something else; after the check the signature is cleared so subsequent reads pass through.","triggerScenarios":"Thrown at interfaces/18-testing/reader.go:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the got/want dumps to see what the actual content is and correct the expected signature.","Abort reading and report the unexpected content type to the user or test.","Verify the URL/resource actually serves the expected file format before streaming."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3c475a78e54336c6255e925ff66b8ef4da6a2ae7","analyzedAt":"2026-09-02T10:14:38.492Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}