From f143b6daca50eba520ceaec51c36222ab6ae667d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 14 Apr 2026 11:08:15 +0300 Subject: fix(r3): use errors.Is for sentinel error comparisons Replace direct == checks with errors.Is so wrapped errors are handled correctly (authkeys Verify, daemon server/EOF, Magefile uninstall). Refs: ask r3, 100 Go Mistakes #51 Made-with: Cursor --- internal/authkeys/store.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'internal/authkeys') diff --git a/internal/authkeys/store.go b/internal/authkeys/store.go index 7848ef8..a8c21c4 100644 --- a/internal/authkeys/store.go +++ b/internal/authkeys/store.go @@ -7,6 +7,7 @@ import ( "crypto/subtle" "database/sql" "encoding/base64" + "errors" "fmt" "path/filepath" "time" @@ -102,7 +103,7 @@ func (s *Store) CreateKey(ctx context.Context, hostname string) (token string, e func (s *Store) Verify(ctx context.Context, hostname, token string) (bool, error) { var stored []byte err := s.db.QueryRowContext(ctx, "SELECT key_hash FROM client_key WHERE hostname = ?", hostname).Scan(&stored) - if err == sql.ErrNoRows { + if errors.Is(err, sql.ErrNoRows) { return false, nil } if err != nil { -- cgit v1.2.3