From 95988f00db46ab65ed1185235b3bfbeadf494821 Mon Sep 17 00:00:00 2001 From: Max Ekman Date: Thu, 10 Apr 2025 16:59:01 +0200 Subject: [PATCH] fix: ignore 'no go files to analyze' error for emtpy folders --- handler.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/handler.go b/handler.go index 99213e9..9f15406 100644 --- a/handler.go +++ b/handler.go @@ -33,10 +33,17 @@ type langHandler struct { rootDir string } +// As defined in the `golangci-lint` source code: +// https://github.com/golangci/golangci-lint/blob/main/pkg/exitcodes/exitcodes.go#L24 +const GoNoFilesExitCode = 5 + func (h *langHandler) errToDiagnostics(err error) []Diagnostic { var message string switch e := err.(type) { case *exec.ExitError: + if e.ExitCode() == GoNoFilesExitCode { + return []Diagnostic{} + } message = string(e.Stderr) default: h.logger.DebugJSON("golangci-lint-langserver: errToDiagnostics message", message)