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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
yuhan6665
2026-09-10 23:16:49 -04:00
parent 7dba75cce3
commit 05238fd2b0
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -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()
}
+2
View File
@@ -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 }