Workaround is to run go test with -vet=off On Fri, 21 Aug 2026 at 10:10, Steven Hartland <[email protected]> wrote:
> Go 1.27 made stdversion checks run by default when running go test as > well as an extra check for errors.Is compatibility. This checks for > non-pointer types which appears to break compatibility with existing code, you > can see this here > https://go.dev/play/p/2nXq9OWS-rf?v=goprev > > Under go 1.26 the errors.Is works as expected but under 1.27 you get a > compile failure. > > If I remove the & so it operates on HTTPError > <https://go.dev/play/p/wLq1L7GMFZn> and not *HTTPError as I believe is > suggested by the vet check two of the tests fail as HTTPError is not > comparable. > > I even tried with a custom Is function defined, go vet check still fails. > > Am I missing something, or is this a significant compatibility breakage > introduced by 1.27? > > With & under 1.27 <https://go.dev/play/p/2nXq9OWS-rf> > > # [play] > ./prog_test.go:27:44: %w wants operand of error type HTTPError, not pointer > type *HTTPError (defeats errors.Is) > Go build failed. > > > Without & on 1.27 <https://go.dev/play/p/wLq1L7GMFZn> > > === RUN TestErrorsIs > === RUN TestErrorsIs/wrapped-eof > === RUN TestErrorsIs/wrapped-sentinel > prog_test.go:37: wrapped: &fmt.wrapError{msg:"wrapped eof error: EOF", > err:main.HTTPError{error:(*errors.errorString)(0x86ae60), StatusCode:404, > Details:[]interface {}{"some extra info"}}} is not sentinel > === RUN TestErrorsIs/direct-sentinel > prog_test.go:42: sentinel: &fmt.wrapError{msg:"wrapped eof error: EOF", > err:main.HTTPError{error:(*errors.errorString)(0x86ae60), StatusCode:404, > Details:[]interface {}{"some extra info"}}} is not sentinel > --- FAIL: TestErrorsIs (0.00s) > --- PASS: TestErrorsIs/wrapped-eof (0.00s) > --- FAIL: TestErrorsIs/wrapped-sentinel (0.00s) > --- FAIL: TestErrorsIs/direct-sentinel (0.00s) > FAIL > Program exited. > > > With & under 1.26 <https://go.dev/play/p/2nXq9OWS-rf?v=goprev> > > === RUN TestErrorsIs > === RUN TestErrorsIs/wrapped-eof > === RUN TestErrorsIs/wrapped-sentinel > === RUN TestErrorsIs/direct-sentinel > --- PASS: TestErrorsIs (0.00s) > --- PASS: TestErrorsIs/wrapped-eof (0.00s) > --- PASS: TestErrorsIs/wrapped-sentinel (0.00s) > --- PASS: TestErrorsIs/direct-sentinel (0.00s) > PASS > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAA38peb_b%3DxM64HUh2dPqQBTYHy6LC2_E-K8-7io_S%2BTjRuP0g%40mail.gmail.com.
