You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's expected. The second argument to errors.As, target, is mutated by the function. You wouldn't call it with a global value like context.DeadlineExceeded; you'd call it on a local error value of a particular type. An example from the errors documentation is:
var perr *os.PathError
if errors.As(err, &perr) {
fmt.Println(perr.Path)
}
If you want to check whether you have an error that matches context.DeadlineExceeded, you'd use errors.Is, not errors.As:
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?
Concurrently calling
errors.As
:https://play.golang.org/p/7FQegBPdSkq
What did you expect to see?
No data race
What did you see instead?
Data race:
The text was updated successfully, but these errors were encountered: