Skip to content
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

x/tools/gopls: add an option to suppress or reduce verbosity of diagnostics for go.mod #51262

Open
esprehn opened this issue Feb 10, 2022 · 6 comments · May be fixed by golang/tools#374
Open
Labels
FeatureRequest gopls/workspace Issues related to support for modules or multi-module workspaces. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@esprehn
Copy link

esprehn commented Feb 10, 2022

We have a project that intentionally has deps in the go.mod that appear unused (ex. because of generated code at build time through bazel). VSCode shows a long list of the below problems.

I've tried the suggestion here:
microsoft/vscode-go#3181

   "[go.mod]": {
        "editor.codeLens": false
    }

and also:

    "ui.codelenses": {
      "gc_details": false,
      "regenerate_cgo": false,
      "generate": false,
      "test": false,
      "tidy": false,
      "upgrade_dependency": false,
      "vendor": false,
    },

but it still shows warnings/errors:

Screen Shot 2022-02-10 at 4 50 25 PM

@suzmue suzmue added gopls Issues related to the Go language server, gopls. FeatureRequest labels Feb 10, 2022
@suzmue
Copy link
Contributor

suzmue commented Feb 10, 2022

The warnings / errors you are seeing are coming from the gopls diagnostics feature. There is currently no way to disable the go mod tidy diagnostics. Leaving this open as a feature request.

@hyangah hyangah changed the title No way to ignore go tidy problems in go.mod x/tools/gopls: add an option to suppress or reduce verbosity of diagnostics for go.mod Feb 18, 2022
@hyangah hyangah transferred this issue from golang/vscode-go Feb 18, 2022
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 18, 2022
@gopherbot gopherbot added this to the Unreleased milestone Feb 18, 2022
@suzmue suzmue modified the milestones: Unreleased, gopls/on-deck Feb 23, 2022
@findleyr
Copy link
Contributor

findleyr commented Mar 7, 2022

I think the correct path forward here is probably to allow disabling gopls' modfile diagnostics (or at least control verbosity) rather than to have syntax in the modfile that is only used by gopls.

Generally we try to avoid any changes to the source that exist only to integrate with a single tool.

@findleyr findleyr added the gopls/workspace Issues related to support for modules or multi-module workspaces. label May 18, 2022
@ybrhue
Copy link

ybrhue commented Aug 3, 2022

Ignoring specific warnings would be really nice.

@sergerad
Copy link

+1 would appreciate a way to disable mod tidy. Or a way to specify -compat=... via env var.

@thumphries-stripe
Copy link

We currently patch this behaviour out of gopls (poorly) and would appreciate a first-class way to completely disable all modfile diagnostics. External tools manage our go.mod / go.sum and vendor tree - we need gopls to trust them and stay away. Large corporate monorepo setting.

@xianbintang
Copy link

xianbintang commented Oct 19, 2023

+1 would appreciate a way to disable mod tidy. Or a way to specify -compat=... via env var.

Add this function in my ~/.zshrc, ~/.bashrc and /etc/bashrc.. etc
It works in my MBP

function go {
    if [[ $1 == "mod" && $2 == "tidy" ]]; then
        command go mod tidy -compat=1.17 "${@:3}"
    else
        command go "$@"
    fi
}

Despite gopls still throwing errors automatically, there are no issues in terms of usability(gopls formatting and importting works now).
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls/workspace Issues related to support for modules or multi-module workspaces. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
8 participants