From 05238fd2b0689f981f47eda8dd7ba89f8eb00f60 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 10 Sep 2026 23:16:49 -0400 Subject: [PATCH] std: address ptrtoerror analyzer diagnostics Gopls' new ptrtoerror analyzer (CL 798580) reports types E such that both E and *E implement error and there is no clear intent as to which one is preferred. This CL cleans up nearly all such diagnostics in std by adding explicit assertions such as 'var _ error = E{}'. Two mistaken uses of scanner.Error (sans &) were fixed, and several unnecessary embeddings of error in tests were change to use a plain named field. Change-Id: I1dbf4abd5750e69c34653a1cdd17fa04edfbc6e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/800560 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Commit-Queue: Alan Donovan Auto-Submit: Alan Donovan --- alert.go | 2 ++ tls.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/alert.go b/alert.go index 577cddc..a196135 100644 --- a/alert.go +++ b/alert.go @@ -12,6 +12,8 @@ import "strconv" // which wraps AlertError rather than sending a TLS alert. type AlertError uint8 +var _ error = AlertError(0) + func (e AlertError) Error() string { return alert(e).String() } diff --git a/tls.go b/tls.go index 970c99d..bdb0ed2 100644 --- a/tls.go +++ b/tls.go @@ -583,6 +583,8 @@ func Listen(network, laddr string, config *Config) (net.Listener, error) { type timeoutError struct{} +var _ error = timeoutError{} + func (timeoutError) Error() string { return "tls: DialWithDialer timed out" } func (timeoutError) Timeout() bool { return true } func (timeoutError) Temporary() bool { return true }