-
Welcome
Description of the problemI am trying to run golangci-lint on this project: https://github.com/estuary/flow It seems to be having issues resolving fields on an embedded struct where the embedded struct is from another package.
If I change the code to reference the embedded field directly it seems to resolve the issue... ie
Version of golangci-lint$ golangci-lint --version
# Paste output here Configuration fileDefault configuration Go environmentgo version go1.16.6 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/data/zbrown/.cache/go-build"
GOENV="/data/zbrown/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/data/git/est/junk/test2/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3806352503=/tmp/go-build -gno-record-gcc-switches"```
</details>
### Verbose output of running
<details>
```console
golangci-lint run -v
INFO [config_reader] Config search paths: [./ /data/git/est/flow /data/git/est /data/git /data / /data/zbrown]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|files|types_sizes|exports_file|imports|name) took 1.217377319s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 13.158632ms
INFO [linters context/goanalysis] analyzers took 51.737400678s with top 10 stages: buildir: 39.729403299s, inspect: 1.968549289s, nilness: 1.469968278s, printf: 1.439017276s, fact_deprecated: 1.428653125s, ctrlflow: 1.423880023s, fact_purity: 944.957097ms, SA5012: 674.113843ms, typedness: 602.028871ms, unused: 125.623659ms
INFO [runner/skip dirs] Skipped 1 issues from dir examples/soak-tests/set-ops by pattern (^|/)examples($|/)
INFO [runner/max_same_issues] 1/4 issues with text "cmd.Ingest undefined (type cmdIngester has no field or method Ingest)" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 2087, after processing: 21
INFO [runner] Processors filtering stat (out/in): path_prefixer: 21/21, path_prettifier: 2087/2087, identifier_marker: 2086/2086, uniq_by_line: 22/2077, max_same_issues: 21/22, max_from_linter: 21/21, path_shortener: 21/21, filename_unadjuster: 2087/2087, exclude-rules: 2077/2086, max_per_file_from_linter: 22/22, severity-rules: 21/21, skip_file
s: 2087/2087, exclude: 2086/2086, nolint: 2077/2077, source_code: 21/21, cgo: 2087/2087, skip_dirs: 2086/2087, autogenerated_exclude: 2086/2086, diff: 22/22, sort_results: 21/21
INFO [runner] processing took 183.437428ms with stages: exclude-rules: 112.287926ms, identifier_marker: 59.256651ms, nolint: 8.788079ms, path_prettifier: 1.317435ms, skip_dirs: 501.68µs, autogenerated_exclude: 406.972µs, source_code: 331.017µs, cgo: 167.538µs, uniq_by_line: 152.088µs, filename_unadjuster: 143.039µs, max_same_issues: 49.67µs, pat
h_shortener: 8.994µs, max_from_linter: 8.334µs, max_per_file_from_linter: 6.325µs, diff: 2.564µs, sort_results: 2.316µs, exclude: 1.912µs, skip_files: 1.859µs, path_prefixer: 1.579µs, severity-rules: 1.45µs
INFO [runner] linters took 8.915159852s with stages: goanalysis_metalinter: 8.731484231s
go/flowctl/cmd-ingester.go:23:42: cmd.Diagnostics undefined (type cmdIngester has no field or method Diagnostics) (typecheck)
defer mbp.InitDiagnosticsAndRecover(cmd.Diagnostics)()
^
...many more of the same
INFO File cache stats: 9 entries of total size 75.2KiB
INFO Memory: 103 samples, avg is 532.3MB, max is 847.1MB
INFO Execution took 10.156456715s Code example or link to a public repository |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 18 replies
-
Hello,
$ go build ./go/flowctl/
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 | return pNew;
| ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 | Select standin;
| ^~~~~~~
# github.com/jgraettinger/gorocksdb
/home/ldez/sources/go/pkg/mod/github.com/jgraettinger/gorocksdb@v0.0.0-20210726190246-aede64bf0e7b/array.go:4:11: fatal error: rocksdb/c.h: No such file or directory
4 | // #include "rocksdb/c.h"
| ^~~~~~~~~~~~~
compilation terminated. $ go build ./go/sql-driver/
# github.com/mattn/go-sqlite3
sqlite3-binding.c: In function ‘sqlite3SelectNew’:
sqlite3-binding.c:128049:10: warning: function may return address of local variable [-Wreturn-local-addr]
128049 | return pNew;
| ^~~~
sqlite3-binding.c:128009:10: note: declared here
128009 | Select standin;
| ^~~~~~~ |
Beta Was this translation helpful? Give feedback.
-
Ahhh Brilliant! It's required to set a bunch of CGO variables before it will compile. Setting those seems to have resolved the issue. Thanks for answering so quickly!!! Sorry the issue seemed so unrelated I didn't think to check that. |
Beta Was this translation helpful? Give feedback.
-
In my case
|
Beta Was this translation helpful? Give feedback.
-
change to |
Beta Was this translation helpful? Give feedback.
-
I use golangci-lint v1.56.0 and go 1.22 in my project. The golangci-lint reports an error like type Procurator struct {
*controller.Group
envServ *EnvServer
} The Mutex field is in the anonymous field type Group struct {
QemuName string
cfg *common.Config
Qoms *qemu.QomMap
Mutex sync.Mutex
Controllers map[string]*Controller
} What confuses me is that the error occurs after I commit a patch in my project. The patch is independent and it does not modify anything related to these structs. But this patch imports a module in our private github server. How can I fix it? |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
I'm getting the same issue with code generated by Mockery getting erroneously flagged - it doesn't "see" methods inherited from For some reason I'm only getting it in a docker container built for CI and not with local macOS installation. I'm using Go 1.23.4 and pre-built v1.62.2 of golangci-lint (installed via Could anyone advise what might be wrong here? looks like some flakiness with the linter and the errors don't really point anywhere. Couldn't infer anything helpful from the discussion above either, so would be grateful for pointers! |
Beta Was this translation helpful? Give feedback.
Ahhh Brilliant! It's required to set a bunch of CGO variables before it will compile. Setting those seems to have resolved the issue. Thanks for answering so quickly!!! Sorry the issue seemed so unrelated I didn't think to check that.