-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Welcome
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've included all information below (version, config, etc).
- Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)
Description of the problem
I add a custom linter to check go projects. And after run that, the output shows that the linter.so was loaded and run in xx us, but the "fmt.Println() " written by the linter did not printed. Also, the custom linter wasn't print in neither "Issue" nor "Report" field of ouput. Why is that?
Version of golangci-lint
Details
$ golangci-lint --version
go version go1.16.5 linux/amd64Configuration file
Details
run:
timeout: 5m
output:
format: json
linters:
disable-all: true
enable:
- my_checker
issues:
exclude-use-default: false
exclude-rules:
- path: ./
linters:
- my_checker
#linters-settings:
linters-settings:
custom:
my_checker:
path: /home/xx/my_checker.so
description: my_checkerGo environment
Details
$ go version && go env
# paste output hereVerbose output of running
Details
$ golangci-lint cache clean
$ export GL_DEBUG=loader,gocritic,env,autogen_exclude,nolint && golangci-lint -v run -c my_debug.yml .
INFO [lintersdb] Active 1 linters: [my_checker]
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 165.727µs
INFO [linters context/goanalysis] analyzers took 18.189µs with top 10 stages: my_checker: 18.189µs
INFO [runner] linters took 1.224164ms with stages: my_checker: 893.899µs
{"Issues":[{"FromLinter":"typecheck","Text":"could not import fmt (Config.Importer.Import(fmt) returned nil but no error)","Severity":"","SourceLines":["\t\"fmt\""],"Replacement":null,"Pos":{"Filename":"main.go","Offset":0,"Line":4,"Column":2},"ExpectNoLint":false,"ExpectedNoLintLinter":""}],"Report":{"Linters":[{"Name":"asciicheck"},{"Name":"bidichk"},{"Name":"bodyclose"},{"Name":"containedctx"},{"Name":"contextcheck"},{"Name":"cyclop"},{"Name":"decorder"},{"Name":"deadcode","EnabledByDefault":true},{"Name":"depguard"},{"Name":"dogsled"},{"Name":"dupl"},{"Name":"durationcheck"},{"Name":"errcheck","EnabledByDefault":true},{"Name":"errchkjson"},{"Name":"errname"},{"Name":"errorlint"},{"Name":"exhaustive"},{"Name":"exhaustivestruct"},{"Name":"exportloopref"},{"Name":"forbidigo"},{"Name":"forcetypeassert"},{"Name":"funlen"},{"Name":"gci"},{"Name":"gochecknoglobals"},{"Name":"gochecknoinits"},{"Name":"gocognit"},{"Name":"goconst"},{"Name":"gocritic"},{"Name":"gocyclo"},{"Name":"godot"},{"Name":"godox"},{"Name":"goerr113"},{"Name":"gofmt"},{"Name":"gofumpt"},{"Name":"goheader"},{"Name":"goimports"},{"Name":"golint"},{"Name":"gomnd"},{"Name":"gomoddirectives"},{"Name":"gomodguard"},{"Name":"goprintffuncname"},{"Name":"gosec"},{"Name":"gosimple","EnabledByDefault":true},{"Name":"govet","EnabledByDefault":true},{"Name":"grouper"},{"Name":"ifshort"},{"Name":"importas"},{"Name":"ineffassign","EnabledByDefault":true},{"Name":"interfacer"},{"Name":"ireturn"},{"Name":"lll"},{"Name":"maintidx"},{"Name":"makezero"},{"Name":"maligned"},{"Name":"misspell"},{"Name":"nakedret"},{"Name":"nestif"},{"Name":"nilerr"},{"Name":"nilnil"},{"Name":"nlreturn"},{"Name":"noctx"},{"Name":"paralleltest"},{"Name":"prealloc"},{"Name":"predeclared"},{"Name":"promlinter"},{"Name":"revive"},{"Name":"rowserrcheck"},{"Name":"scopelint"},{"Name":"sqlclosecheck"},{"Name":"staticcheck","EnabledByDefault":true},{"Name":"structcheck","EnabledByDefault":true},{"Name":"stylecheck"},{"Name":"tagliatelle"},{"Name":"tenv"},{"Name":"testpackage"},{"Name":"thelper"},{"Name":"tparallel"},{"Name":"typecheck","EnabledByDefault":true},{"Name":"unconvert"},{"Name":"unparam"},{"Name":"unused","EnabledByDefault":true},{"Name":"varcheck","EnabledByDefault":true},{"Name":"varnamelen"},{"Name":"wastedassign"},{"Name":"whitespace"},{"Name":"wrapcheck"},{"Name":"wsl"},{"Name":"nolintlint"}]}}Code example or link to a public repository
Details
package main
import (
"fmt"
"go/ast"
"os"
"golang.org/x/tools/go/analysis"
)
type analyzerPlugin struct{}
func (*analyzerPlugin) GetAnalyzers() []*analysis.Analyzer {
return []*analysis.Analyzer{
My_CHECKERAnalyzer,
}
}
var AnalyzerPlugin analyzerPlugin
var MY_CHECKERAnalyzer = &analysis.Analyzer{
Name: "my_checker",
Doc: "limit_for_the_use_of_context",
Run: run,
}
func run(pass *analysis.Pass) (interface{}, error) {
fmt.Println(" test args:")
for _, file := range pass.Files {
ast.Inspect(file, func(n ast.Node) bool {
fmt.Fprintf(os.Stderr, "test1: \n")
msg := "test123"
pass.Report(analysis.Diagnostic{
Pos: n.Pos(),
End: n.End(),
Category: "my_checker",
Message: msg,
})
return true
})
}
return nil, nil
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working