Skip to content

typecheck: type <struct> has no field or method <Field on embedded struct from another package> #2286

@snowzach

Description

@snowzach

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 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.

$ golangci-lint run
go/flowctl/cmd-ingester.go:23:42: cmd.Diagnostics undefined (type cmdIngester has no field or method Diagnostics) (typecheck)
        defer mbp.InitDiagnosticsAndRecover(cmd.Diagnostics)()
                                                ^

If I change the code to reference the embedded field directly it seems to resolve the issue... ie

defer mbp.InitDiagnosticsAndRecover(cmd.FlowIngesterConfig.Diagnostics)()

Version of golangci-lint

$ golangci-lint --version
# Paste output here

Configuration file

Default configuration

Go environment

go 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

https://github.com/estuary/flow

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions