The unused linter does not detect unused exported struct members when "exported-fields-are-used" configuration is set to false.
Version of golangci-lint
```console
$ golangci-lint --version
golangci-lint has version 1.60.3 built with go1.23.0 from c2e095c on 2024-08-22T21:45:24Z
```
Configuration
```console
--config <(echo '{"linters-settings":{"unused":{"exported-fields-are-used":false}}}')
```
this is equivalent to the yaml config
```console
linter-settings:
unused:
exported-fields-are-used: false
```
```console
$ 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
```
A minimal reproducible example or link to a public repository
```go
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.
Validation
[X] Yes, I've included all information above (version, config, etc.).
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
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Validation
Supporter