Skip to content

typecheck: X imported but not used although it's used #4252

@mojixcoder

Description

@mojixcoder

Welcome

Description of the problem

After running golang-ci with this command: golangci-lint run --skip-dirs='(.docker|.k6|.okd|.scripts|docs)' --timeout=5m

I get this error:

privent/privent.go:6:2: "net" imported and not used (typecheck)
	"net"
	^

But it's clearly used in this file:

if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
	// Do something...
}

Version of golangci-lint

Docker image: golangci/golangci-lint:v1.55.2

Configuration

My project uses Go 1.20.

Go environment

No extra Configuration.

Verbose output of running

level=info msg="[config_reader] Config search paths: [./ /builds/Map/location/colony /builds/Map/location /builds/Map /builds / /root]"
level=info msg="[lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]"
level=info msg="[loader] Go packages loading at mode 575 (exports_file|files|name|compiled_files|deps|imports|types_sizes) took 23.988927144s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 8.435833ms"
level=info msg="[linters_context/goanalysis] analyzers took 49.354770662s with top 10 stages: buildir: 38.461180884s, inspect: 2.928883314s, fact_deprecated: 1.8836694s, printf: 1.416356947s, ctrlflow: 1.169159743s, nilness: 993.049038ms, fact_purity: 874.906921ms, SA5012: 759.391302ms, typedness: 626.246842ms, testinggoroutine: 6.077466ms"
level=info msg="[runner] Issues before processing: 145, after processing: 1"
level=info msg="[runner] Processors filtering stat (out/in): exclude: 145/145, nolint: 145/145, severity-rules: 1/1, sort_results: 1/1, skip_files: 145/145, path_prettifier: 145/145, skip_dirs: 145/145, diff: 1/1, cgo: 145/145, identifier_marker: 145/145, exclude-rules: 145/145, uniq_by_line: 1/145, max_same_issues: 1/1, max_from_linter: 1/1, source_code: 1/1, path_shortener: 1/1, filename_unadjuster: 145/145, path_prefixer: 1/1, fixer: 1/1, max_per_file_from_linter: 1/1, autogenerated_exclude: 145/145"
level=info msg="[runner] processing took 4.004809ms with stages: identifier_marker: 2.034301ms, exclude-rules: 1.395694ms, nolint: 303.352µs, path_prettifier: 119.914µs, source_code: 43.388µs, skip_dirs: 41.216µs, cgo: 14.57µs, uniq_by_line: 13.673µs, filename_unadjuster: 11.526µs, autogenerated_exclude: 11.383µs, max_same_issues: 8.26µs, max_per_file_from_linter: 1.746µs, path_shortener: 1.56µs, max_from_linter: 1.245µs, skip_files: 716ns, fixer: 463ns, exclude: 446ns, severity-rules: 412ns, diff: 403ns, sort_results: 313ns, path_prefixer: [22](https://gitlab.snapp.ir/Map/location/colony/-/jobs/2468317#L22)8ns"
level=info msg="[runner] linters took 8.2608[24](https://gitlab.snapp.ir/Map/location/colony/-/jobs/2468317#L24)519s with stages: goanalysis_metalinter: 8.[25](https://gitlab.snapp.ir/Map/location/colony/-/jobs/2468317#L25)664683s"
level=info msg="File cache stats: 1 entries of total size 1.2KiB"
privent/privent.go:6:2: "net" imported and not used (typecheck)
	"net"
	^
level=info msg="Memory: 324 samples, avg is 162.4MB, max is 806.6MB"
level=info msg="Execution took 32.[27](https://gitlab.snapp.ir/Map/location/colony/-/jobs/2468317#L27)5509143s"

A minimal reproducible example or link to a public repository

// add your code here

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