diff --git a/cmd/zoekt-webserver/main.go b/cmd/zoekt-webserver/main.go index d9e5c5773..1055d0cf4 100644 --- a/cmd/zoekt-webserver/main.go +++ b/cmd/zoekt-webserver/main.go @@ -308,7 +308,7 @@ func main() { err = srv.ListenAndServe() } - if err != http.ErrServerClosed { + if !errors.Is(err, http.ErrServerClosed) { // Fatal otherwise shutdownOnSignal will block log.Fatalf("ListenAndServe: %v", err) } diff --git a/gitindex/catfile.go b/gitindex/catfile.go index 1933c337c..7e626a89b 100644 --- a/gitindex/catfile.go +++ b/gitindex/catfile.go @@ -18,6 +18,7 @@ import ( "bufio" "bytes" "encoding/hex" + "errors" "fmt" "io" "os/exec" @@ -235,8 +236,8 @@ func (cr *catfileReader) Close() error { // isKilledErr reports whether err is an exec.ExitError caused by SIGKILL. func isKilledErr(err error) bool { - exitErr, ok := err.(*exec.ExitError) - if !ok { + var exitErr *exec.ExitError + if !errors.As(err, &exitErr) { return false } ws, ok := exitErr.Sys().(syscall.WaitStatus) diff --git a/gitindex/index.go b/gitindex/index.go index 3e9f4b6bd..5ab0ce205 100644 --- a/gitindex/index.go +++ b/gitindex/index.go @@ -823,7 +823,7 @@ func catfileFilterSpec(opts Options) string { func newIgnoreMatcher(tree *object.Tree) (*ignore.Matcher, error) { ignoreFile, err := tree.File(ignore.IgnoreFile) - if err == object.ErrFileNotFound { + if errors.Is(err, object.ErrFileNotFound) { return &ignore.Matcher{}, nil } if err != nil { diff --git a/internal/archive/archive.go b/internal/archive/archive.go index 2048a25fb..b015abb8a 100644 --- a/internal/archive/archive.go +++ b/internal/archive/archive.go @@ -5,6 +5,7 @@ import ( "archive/zip" "bytes" "compress/gzip" + "errors" "fmt" "io" "net/http" @@ -114,7 +115,7 @@ func newZipArchive(r io.Reader, closer io.Closer) (*zipArchive, error) { func detectContentType(r io.Reader) (string, io.Reader, error) { var buf [512]byte n, err := io.ReadFull(r, buf[:]) - if err != nil && err != io.ErrUnexpectedEOF { + if err != nil && !errors.Is(err, io.ErrUnexpectedEOF) { return "", nil, err } diff --git a/search/watcher.go b/search/watcher.go index 102418ee2..53cc0dbe0 100644 --- a/search/watcher.go +++ b/search/watcher.go @@ -15,6 +15,7 @@ package search import ( + "errors" "fmt" "log" "os" @@ -244,7 +245,7 @@ func (s *DirectoryWatcher) watch() error { case err := <-watcher.Errors: // Ignore ErrEventOverflow since we rely on the presence of events so // safe to ignore. - if err != nil && err != fsnotify.ErrEventOverflow { + if err != nil && !errors.Is(err, fsnotify.ErrEventOverflow) { log.Println("[ERROR] watcher error:", err) }