From cca68dcffe765579343d200d70e86af9cde01241 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Tue, 27 Dec 2022 10:48:48 +0100 Subject: [PATCH] doc: improve documentation about debugging. (#3434) --- docs/src/docs/contributing/debug.mdx | 25 +++++++++++++++++-------- pkg/logutils/logutils.go | 14 +++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/docs/src/docs/contributing/debug.mdx b/docs/src/docs/contributing/debug.mdx index e362ce66..e8072eb0 100644 --- a/docs/src/docs/contributing/debug.mdx +++ b/docs/src/docs/contributing/debug.mdx @@ -4,12 +4,21 @@ title: Debugging You can see a verbose output of linter by using `-v` option. -If you would like to see more detailed logs you can set environment variable `GL_DEBUG` to debug `golangci-lint`. -It's value is a list of debug tags. For example, `GL_DEBUG=loader,gocritic golangci-lint run`. -Existing debug tags: +```bash +golangci-lint run -v +``` -1. `gocritic` - debug `go-critic` linter; -2. `env` - debug `go env` command; -3. `loader` - debug packages loading (including `go/packages` internal debugging); -4. `autogen_exclude` - debug a filter excluding autogenerated source code; -5. `nolint` - debug a filter excluding issues by `//nolint` comments. +If you would like to see more detailed logs you can use the environment variable `GL_DEBUG`. +Its value is a list of debug tags. + +The existing debug tags are documented in the following file: https://github.com/golangci/golangci-lint/blob/master/pkg/logutils/logutils.go + +For example: + +```bash +GL_DEBUG="loader,gocritic" golangci-lint run +``` + +```bash +GL_DEBUG="loader,env" golangci-lint run +``` diff --git a/pkg/logutils/logutils.go b/pkg/logutils/logutils.go index 710f084a..62c521ea 100644 --- a/pkg/logutils/logutils.go +++ b/pkg/logutils/logutils.go @@ -13,12 +13,12 @@ import ( const envDebug = "GL_DEBUG" const ( - DebugKeyAutogenExclude = "autogen_exclude" + DebugKeyAutogenExclude = "autogen_exclude" // Debugs a filter excluding autogenerated source code. DebugKeyBinSalt = "bin_salt" DebugKeyConfigReader = "config_reader" DebugKeyEmpty = "" DebugKeyEnabledLinters = "enabled_linters" - DebugKeyEnv = "env" + DebugKeyEnv = "env" // Debugs `go env` command. DebugKeyExcludeRules = "exclude_rules" DebugKeyExec = "exec" DebugKeyFilenameUnadjuster = "filename_unadjuster" @@ -27,7 +27,7 @@ const ( DebugKeyLintersContext = "linters_context" DebugKeyLintersDB = "lintersdb" DebugKeyLintersOutput = "linters_output" - DebugKeyLoader = "loader" + DebugKeyLoader = "loader" // Debugs packages loading (including `go/packages` internal debugging). DebugKeyMaxFromLinter = "max_from_linter" DebugKeyMaxSameIssues = "max_same_issues" DebugKeyPkgCache = "pkgcache" @@ -55,10 +55,10 @@ const ( ) const ( - DebugKeyGoCritic = "gocritic" - DebugKeyMegacheck = "megacheck" - DebugKeyNolint = "nolint" - DebugKeyRevive = "revive" + DebugKeyGoCritic = "gocritic" // Debugs `go-critic` linter. + DebugKeyMegacheck = "megacheck" // Debugs `staticcheck` related linters. + DebugKeyNolint = "nolint" // Debugs a filter excluding issues by `//nolint` comments. + DebugKeyRevive = "revive" // Debugs `revice` linter. ) func getEnabledDebugs() map[string]bool {