Skip to content

govet: printf unstable behavior with imported types #4423

Open
@gabolaev

Description

Welcome

Description of the problem

Hi, we've encountered some strange behavior with the govet printf linter.

If we edit the previously reported file without fixing the issue, it stops reporting the issue. However, if we clean the cache, it gets back to normal, but I'm not sure we're supposed to clean the cache before every run.

asciicast

There is one interesting detail that I think may be a clue though.
It stops being unstable if we change the code so that it doesn't import logger, but initializes log in place:

 package somepackage
 
-import "reproduction/logger"
+import "github.com/sirupsen/logrus"
 
-var log = logger.NewLogger()
+var log = logrus.New()
 
 func SomeFunc() {
        log.Warnf("SOME OTHER TEXT %v") // this line is supposed to be reported by govet printf linter
 }

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a on 2024-02-15T12:52:06Z

Configuration

linters:
  disable-all: true
  enable:
    - govet

Go environment

$ go version && go env
go version go1.22.0 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/gabolaev/Library/Caches/go-build'
GOENV='/Users/gabolaev/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/gabolaev/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/gabolaev/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/gabolaev/d/reproduction/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/k1/pd5ymz911jl6gdx0zgj85cym0000gq/T/go-build3537487068=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ # golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/gabolaev/d/reproduction /Users/gabolaev/d /Users/gabolaev /Users /] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (files|compiled_files|deps|exports_file|imports|name|types_sizes) took 80.6465ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 671.333µs 
INFO [linters_context/goanalysis] analyzers took 22.21121ms with top 10 stages: buildir: 4.840833ms, fact_deprecated: 1.047916ms, ctrlflow: 868.047µs, errcheck: 710.334µs, SA9002: 663.334µs, printf: 639.212µs, SA4020: 559.833µs, SA4019: 559.667µs, unused: 544.792µs, ineffassign: 540.792µs 
INFO [runner] processing took 998ns with stages: max_same_issues: 333ns, skip_dirs: 167ns, nolint: 125ns, sort_results: 125ns, max_from_linter: 42ns, diff: 42ns, exclude-rules: 41ns, max_per_file_from_linter: 41ns, severity-rules: 41ns, autogenerated_exclude: 41ns, path_prettifier: 0s, skip_files: 0s, path_shortener: 0s, path_prefixer: 0s, uniq_by_line: 0s, exclude: 0s, filename_unadjuster: 0s, source_code: 0s, fixer: 0s, cgo: 0s, identifier_marker: 0s 
INFO [runner] linters took 95.207125ms with stages: goanalysis_metalinter: 94.983417ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 3 samples, avg is 32.2MB, max is 39.6MB 
INFO Execution took 184.939709ms                  

A minimal reproducible example or link to a public repository

https://github.com/gabolaev/gl-issue-reproduction

Validation

  • Yes, I've included all information above (version, config, etc.).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions