Skip to content

Directory prefix src does not contain main module or its selected dependencies #4189

@stephanwesten

Description

@stephanwesten

Welcome

Description of the problem

I searched for similar issues, but it is pretty subtle so I can't tell for sure. Feel free to close as duplicate.

To reproduce, create a new folder 'testgolint', with a 'src' folder and two files: go.main and go.mod:

➜  testgolint ls -R
src

./src:
go.mod  main.go

Run the linter:

➜  testgolint golangci-lint run src/...
ERRO [linters_context] typechecking error: pattern ./src/...: directory prefix src does not contain main module or its selected dependencies

➜  testgolint golangci-lint run src    
ERRO Running error: context loading failed: no go files to analyze

env:

➜  testgolint go env GOPATH
/Users/xyz/go

➜  testgolint go version 
go version go1.20.4 darwin/arm64

Version of golangci-lint

$ golangci-lint --versiontestgolint golangci-lint --version
golangci-lint has version 1.55.2 built with go1.21.3 from e3c2265f on 2023-11-03T12:59:25Z

Configuration

# paste configuration file or CLI flags here

n/a

Go environment

see description, don't want to paste all info unless it is really needed

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/stephan.westen/projects/testgolint /Users/stephan.westen/projects /Users/stephan.westen /Users /] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (imports|name|compiled_files|deps|exports_file|files|types_sizes) took 17.879708ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 24.125µs 
ERRO [linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies 
INFO [linters_context/goanalysis] analyzers took 2.299212ms with top 10 stages: fact_deprecated: 511.167µs, buildir: 408.584µs, typecheck: 113.875µs, ineffassign: 103.208µs, httpresponse: 87.834µs, S1003: 80.333µs, framepointer: 71.917µs, S1016: 71.458µs, unmarshal: 65.834µs, SA4000: 62.584µs 
INFO [runner] processing took 1.288µs with stages: max_same_issues: 208ns, skip_files: 166ns, skip_dirs: 166ns, path_prettifier: 83ns, nolint: 83ns, path_prefixer: 42ns, filename_unadjuster: 42ns, fixer: 42ns, sort_results: 42ns, severity-rules: 42ns, diff: 42ns, cgo: 42ns, exclude-rules: 42ns, uniq_by_line: 41ns, max_per_file_from_linter: 41ns, max_from_linter: 41ns, autogenerated_exclude: 41ns, identifier_marker: 41ns, source_code: 41ns, exclude: 0s, path_shortener: 0s 
INFO [runner] linters took 12.61375ms with stages: goanalysis_metalinter: 12.575917ms 
INFO File cache stats: 0 entries of total size 0B 
INFO Memory: 2 samples, avg is 27.4MB, max is 27.7MB 
INFO Execution took 43.000541ms

A minimal reproducible example or link to a public repository

see describes

Validation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions