We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
typecheck
The unused linter does not detect unused exported struct members when "exported-fields-are-used" configuration is set to false.
unused
false
$ golangci-lint --version golangci-lint has version 1.60.3 built with go1.23.0 from c2e095c on 2024-08-22T21:45:24Z
--config <(echo '{"linters-settings":{"unused":{"exported-fields-are-used":false}}}')
this is equivalent to the yaml config
linter-settings: unused: exported-fields-are-used: false
$ go version && go env go version go1.23.0 darwin/arm64 GO111MODULE='' GOARCH='arm64' GOBIN='' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/opt/homebrew/Cellar/go/1.23.0/libexec' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='local' GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.0/libexec/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.23.0' GODEBUG='' GOTELEMETRY='local' GCCGO='gccgo' GOARM64='v8.0' AR='ar' CC='cc' CXX='c++' CGO_ENABLED='1' GOMOD='/dev/null' 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/s2/32jxgw6j2tl3lr6q7_p_0_th0000gn/T/go-build3082553639=/tmp/go-build -gno-record-gcc-switches -fno-common'
$ golangci-lint cache clean $ golangci-lint run --config <(echo '{"linters-settings":{"unused":{"exported-fields-are-used":false}}}') blah.go -v INFO golangci-lint has version 1.60.3 built with go1.23.0 from c2e095c on 2024-08-22T21:45:24Z INFO [config_reader] Used config file ../../dev/fd/11 INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] INFO [loader] Go packages loading at mode 575 (files|types_sizes|exports_file|deps|imports|name|compiled_files) took 67.919958ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 126.334µs INFO [linters_context/goanalysis] analyzers took 853.935539ms with top 10 stages: buildir: 636.946627ms, printf: 33.912087ms, SA5012: 29.531086ms, ctrlflow: 29.333536ms, fact_deprecated: 27.19442ms, inspect: 26.515128ms, nilness: 23.992833ms, fact_purity: 23.913584ms, typedness: 19.195332ms, tokenfileanalyzer: 2.332332ms INFO [runner] processing took 2.086µs with stages: max_same_issues: 375ns, filename_unadjuster: 208ns, skip_dirs: 167ns, identifier_marker: 167ns, nolint: 167ns, path_prettifier: 125ns, skip_files: 125ns, source_code: 125ns, cgo: 125ns, invalid_issue: 125ns, path_shortener: 42ns, uniq_by_line: 42ns, fixer: 42ns, max_per_file_from_linter: 42ns, autogenerated_exclude: 42ns, diff: 42ns, exclude: 42ns, max_from_linter: 42ns, sort_results: 41ns, path_prefixer: 0s, exclude-rules: 0s, severity-rules: 0s INFO [runner] linters took 581.634083ms with stages: goanalysis_metalinter: 581.611875ms INFO File cache stats: 0 entries of total size 0B INFO Memory: 8 samples, avg is 150.9MB, max is 231.2MB INFO Execution took 657.469ms
package main import "fmt" type Foo struct { Bar string Baz string } func main() { f := Foo{} fmt.Println(f.Baz) }
Please note: if you unexport Bar, the linter works as expected.
Bar
The text was updated successfully, but these errors were encountered:
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
Sorry, something went wrong.
duplicate of #4218
No branches or pull requests
Welcome
typecheck
section of the FAQ.Description of the problem
The
unused
linter does not detect unused exported struct members when "exported-fields-are-used" configuration is set tofalse
.Version of golangci-lint
Configuration
--config <(echo '{"linters-settings":{"unused":{"exported-fields-are-used":false}}}')
this is equivalent to the yaml config
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Please note: if you unexport
Bar
, the linter works as expected.Validation
Supporter
The text was updated successfully, but these errors were encountered: