Skip to content

fix: Error code 5 with golangci-lint v2 #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stefanbildl
Copy link

I had the same problems with exit code 5 using golangci-lint version 2 as mentioned in #744.

The comment by @brunofjesus #744 (comment) helped me solve part of the issue.

I added code that goes up the directory tree to find the go mod file.
Also I added /... to the end of the path to handle some weird cases where golangci-lint still complained.

This seems to fix the issue with error code 5 for me. The problem with exit code 7 is still unresolved

@stefanbildl
Copy link
Author

related to #761

@mzeiher
Copy link

mzeiher commented Apr 15, 2025

Hi, as an alternative I came up with for this error is keeping the arguments and just changing the current working dir. This fixes the issues in our monorepo...

local getCwd = function()
  local current = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":h")
  local found = vim.fs.find("go.mod", {
    upward = true,
    path = current,
  })
  return #found > 0 and vim.fn.fnamemodify(found[1], ":h") or vim.fn.getcwd()
end

return {
  cmd = "golangci-lint",
  append_fname = false,
  args = getArgs(),
  stream = "stdout",
  cwd = getCwd(),
...

just fyi...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants