Skip to content

linters_context generating typechecking error about malformed import path for files and folders in issues.exclude-dirs #4659

Closed
@MistaTwista

Description

@MistaTwista

Welcome

Description of the problem

I have a project where go files generating from paths that looks like internal/snippet/some{{ .Metadata.Name }}/packageName/something.go. I process them with golang template engine, so in a final project it's ok)

I've set option to exclude-dirs in config.
The problem here is that folders actually are not skipped.

I see error like:
typechecking error: malformed import path "...some{{.Metadata.Name}}": invalid char '{'

The question is is this a bug or if I need to template something I should use .tmpl files instead of .go? But what about to skip directories completely?

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.57.2 built with go1.22.1 from 77a8601 on 2024-03-28T18:39:06Z

Configuration

issues:
  exclude-dirs:
    - internal/snippet

Go environment

$ go version && go env
go version go1.21.6 darwin/amd64
GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOOS='darwin'
GOPROXY='direct'
GOSUMDB='off'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [/Users/mistatwista/go/src /Users/mistatwista/go /Users/mistatwista /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 74 linters: [asasalint asciicheck bidichk bodyclose contextcheck cyclop decorder dogsled dupl errcheck errchkjson errname errorlint execinquery exhaustive exportloopref forbidigo forcetypeassert funlen gci gochecknoglobals gochecknoinits gocognit goconst gocritic godot godox goerr113 gofmt gofumpt goheader goimports gomnd gomoddirectives gomodguard goprintffuncname gosec gosimple govet grouper importas ineffassign ireturn lll maintidx makezero misspell nakedret nestif nilerr nilnil nlreturn noctx nolintlint nosprintfhostport paralleltest prealloc predeclared promlinter revive rowserrcheck sqlclosecheck staticcheck tagliatelle tenv thelper tparallel unconvert unparam unused usestdlibvars wastedassign whitespace wsl]
INFO [loader] Go packages loading at mode 575 (exports_file|imports|files|name|types_sizes|compiled_files|deps) took 1.137843266s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 6.726087ms
INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key.
ERRO [linters_context] typechecking error: malformed import path "... internal/snippet/some{{.Metadata.Name}}": invalid char '{'
INFO [linters_context/goanalysis] analyzers took 14.285252ms with top 10 stages: fact_deprecated: 1.315369ms, buildir: 1.138168ms, S1021: 679.879µs, SA4021: 666.613µs, nilerr: 630.405µs, SA9006: 609.793µs, commentmap: 605.164µs, S1039: 604.204µs, tagliatelle: 604.203µs, gosec: 593.179µs
INFO [runner] Issues before processing: 383, after processing: 0
INFO [runner] Processors filtering stat (out/in): filename_unadjuster: 383/383, invalid_issue: 383/383, autogenerated_exclude: 383/383, exclude-rules: 202/383, cgo: 383/383, skip_files: 383/383, skip_dirs: 383/383, identifier_marker: 383/383, nolint: 0/202, path_prettifier: 383/383, exclude: 383/383
INFO [runner] processing took 40.010755ms with stages: exclude-rules: 15.646809ms, nolint: 12.484288ms, identifier_marker: 9.554098ms, path_prettifier: 1.182333ms, autogenerated_exclude: 878.819µs, skip_dirs: 208.593µs, cgo: 20.813µs, invalid_issue: 16.718µs, filename_unadjuster: 13.237µs, max_same_issues: 976ns, path_shortener: 632ns, exclude: 481ns, fixer: 481ns, uniq_by_line: 420ns, skip_files: 345ns, diff: 305ns, max_from_linter: 289ns, path_prefixer: 241ns, sort_results: 239ns, source_code: 237ns, severity-rules: 220ns, max_per_file_from_linter: 181ns
INFO [runner] linters took 879.282409ms with stages: goanalysis_metalinter: 839.105891ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 22 samples, avg is 42.6MB, max is 84.1MB
INFO Execution took 2.04524279s

A minimal reproducible example or link to a public repository

git@github.com:MistaTwista/templado.git
cd templado
golangci-lint run

ERRO [linters_context] typechecking error: malformed import path "github.com/MistaTwista/templado/internal/snippets/es-{{ .Metadata.Name }}": invalid char '{'

echo $?

7

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