net: can't unwrap DNSError #63109
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
YES.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The release notes for Go 1.19 mention the following specification about the "operation was canceled" error in the
net
package:However, when I execute
errors.Is(err, context.Canceled)
against the "operation was canceled" error that returns from methods like*Dialer.DialContext
, it does not evaluate totrue
. Is this in accordance with the specification?https://go.dev/play/p/Os-LQrrlUx6
Looking at the execution result, it appears that the
*net.DNSError
within the*net.OpError
has not implemented theUnwrap
method. If theErr
field in theDNSError
struct retained its value as anerror
type, I believe theIs
method oferrCanceled
(of typecanceledError
) from thenet
package would be called, anderrors.Is(err, context.Canceled)
would returntrue
.https://pkg.go.dev/net#DNSError
https://github.com/golang/go/blob/go1.21.1/src/net/net.go#L411-L422
What did you expect to see?
When a net package function returns an "operation was canceled" error,
errors.Is(err, context.Canceled)
returnstrue
.What did you see instead?
When a net package function returns an "operation was canceled" error,
errors.Is(err, context.Canceled)
returnsfalse
.The text was updated successfully, but these errors were encountered: