diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-14 11:08:15 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-14 11:08:15 +0300 |
| commit | f143b6daca50eba520ceaec51c36222ab6ae667d (patch) | |
| tree | 18cc8299b0e87fd8e633334abf74f57fd77f2a44 /internal/authkeys | |
| parent | 9d32b8138baf821d72eb1f5a7a218f9b1949c853 (diff) | |
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
Diffstat (limited to 'internal/authkeys')
| -rw-r--r-- | internal/authkeys/store.go | 3 |
1 files changed, 2 insertions, 1 deletions
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 { |
