Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.53.1 Depguard error #3877

Closed
4 tasks done
piotratlz opened this issue Jun 2, 2023 · 11 comments
Closed
4 tasks done

v1.53.1 Depguard error #3877

piotratlz opened this issue Jun 2, 2023 · 11 comments
Labels
question Further information is requested

Comments

@piotratlz
Copy link

piotratlz commented Jun 2, 2023

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 (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

Issue occurs on golangci github action with standard configuration and latest version

run golangci-lint
  Running [/home/runner/golangci-lint-1.53.1-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
    Error: import 'github.com/google/wire' is not allowed from list 'Main' (depguard)

Version of golangci-lint

$ golangci-lint --version
v1.53.1

Configuration file

$ cat .golangci.yml
go: "1.20"
linters:
  disable-all: true
  enable:
    - bodyclose
    - contextcheck
    - depguard
    - dogsled
    - dupl
    - errcheck
    - errname
    - exhaustive
    - exportloopref
    - funlen
    - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - gofmt
    - goimports
    - gosec
    - gosimple
    - govet
    - ineffassign
    - makezero
    - misspell
    - nakedret
    - nilnil
    - paralleltest
    - staticcheck
    - stylecheck
    - typecheck
    - unconvert
    - unparam
    - unused
run:
  timeout: 5m
  skip-files:
    - .*/ent/.*
    - .*/mocks/.*
    - \\_gen.go$
  modules-download-mode: readonly
issues:
  exclude-rules:
    - path: .*_test.go
      linters:
        - funlen
        - gosec
        - dupl

Go environment

$ go version && go env
go version go1.20.4 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/runner/.cache/go-build"
GOENV="/home/runner/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/runner/go/pkg/mod"
GONOPROXY="<hidden>"
GONOSUMDB="<hidden>"
GOOS="linux"
GOPATH="/home/runner/go"
GOPRIVATE="<hidden>"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/hostedtoolcache/go/1.20.4/x64"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/hostedtoolcache/go/1.20.4/x64/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/runner/work/<hidden>/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build354993[7](<hidden>)465=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
Running [/home/runner/golangci-lint-1.53.1-linux-amd64/golangci-lint run --out-format=github-actions -v] in [] ...
  Error: import 'github.com/google/uuid' is not allowed from list 'Main' (depguard)

  level=info msg="[config_reader] Config search paths: [./ /home/runner/work/<hidden> /home/runner/work/<hidden> /home/runner/work /home/runner /home /]"
  level=info msg="[config_reader] Used config file .golangci.yml"
  level=info msg="[lintersdb] Active 34 linters: [bodyclose contextcheck depguard dogsled dupl errcheck errname exhaustive exportloopref funlen gochecknoinits goconst gocritic gocyclo gofmt goimports gosec gosimple govet ineffassign makezero misspell nakedret nilerr nilnil paralleltest prealloc reassign staticcheck stylecheck typecheck unconvert unparam unused]"
  level=info msg="[loader] Go packages loading at mode 575 (exports_file|files|imports|name|compiled_files|deps|types_sizes) took 959.823517ms"
  level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 88.256865ms"
  level=info msg="[linters_context/goanalysis] analyzers took 0s with no stages"
  level=info msg="[runner/max_same_issues] 73/76 issues with text \"import 'github.com/google/uuid' is not allowed from list 'Main'\" were hidden, use --max-same-issues"
  level=info msg="[runner/max_from_linter] 110/160 issues from linter depguard were hidden, use --max-issues-per-linter"
  level=info msg="[runner] Issues before processing: 1974, after processing: 50"
  level=info msg="[runner] Processors filtering stat (out/in): path_prefixer: 50/50, cgo: 1974/1974, filename_unadjuster: 1974/1974, autogenerated_exclude: 1050/1084, exclude: 1050/1050, max_per_file_from_linter: 770/770, max_same_issues: 160/770, source_code: 50/50, sort_results: 50/50, path_prettifier: 1974/1974, severity-rules: 50/50, skip_files: 1084/1974, max_from_linter: 50/160, fixer: 50/50, skip_dirs: 1084/1084, identifier_marker: 1050/1050, exclude-rules: 778/1050, nolint: 770/778, uniq_by_line: 770/770, diff: 770/770, path_shortener: 50/50"
  level=info msg="[runner] processing took 116.557204ms with stages: nolint: 41.601002ms, exclude-rules: 39.012171ms, identifier_marker: 19.613237ms, path_prettifier: 5.953472ms, skip_files: 5.618668ms, autogenerated_exclude: 2.929035ms, skip_dirs: 506.706µs, max_same_issues: 399.704µs, source_code: 389.204µs, cgo: 173.602µs, uniq_by_line: 165.001µs, filename_unadjuster: 113.501µs, max_per_file_from_linter: 41.4µs, max_from_linter: 21.701µs, path_shortener: 17.1µs, exclude: 400ns, fixer: 400ns, diff: 300ns, severity-rules: 200ns, path_prefixer: 200ns, sort_results: 200ns"
  level=info msg="[runner] linters took 2.009183852s with stages: goanalysis_metalinter: 1.892501544s"
  level=info msg="File cache stats: 12 entries of total size 139.6KiB"
  level=info msg="Memory: 32 samples, avg is 48.5MB, max is 92.9MB"
  level=info msg="Execution took 3.064274417s"
  
  Error: issues found
  Ran golangci-lint in 3177ms

Code example or link to a public repository

// add your code here
@piotratlz piotratlz added the bug Something isn't working label Jun 2, 2023
@dannyskoog

This comment was marked as off-topic.

@ldez
Copy link
Member

ldez commented Jun 2, 2023

Can you provide your configuration?

Can you fill in the required sections in the issue description?

Note: The depguard configuration has completely changed.

@ldez ldez added the feedback required Requires additional feedback label Jun 2, 2023
@ldez
Copy link
Member

ldez commented Jun 2, 2023

If you are facing the same problem, the best way to contribute is to provide the following information:

golangci-lint --version
cat .golangci.yml
go version && go env
golangci-lint cache clean
golangci-lint run -v

And a code example or link to a public repository.


If you are not able to provide that information, please just add a 👍 to the issue description, thank you.

@piotratlz
Copy link
Author

piotratlz commented Jun 2, 2023

@ldez I included commands outputs in the description
I apologize for not including them before.

@ldez
Copy link
Member

ldez commented Jun 2, 2023

Then it's because you are using depguard without any configuration.

You have to either add a configuration or disable depguard.

The default rule of depguard is to allow only std lib in all files.

@ldez ldez added question Further information is requested and removed bug Something isn't working feedback required Requires additional feedback labels Jun 2, 2023
@kings-wang

This comment was marked as off-topic.

@ldez

This comment was marked as off-topic.

@ldez
Copy link
Member

ldez commented Jun 2, 2023

I will close this issue as it is the expected new behavior.

@ldez ldez closed this as completed Jun 2, 2023
@piotratlz
Copy link
Author

Follow up:

In order to fix depguard you need to configure depguard in golangci.yml and explicitly allow packages, example:

linters-settings:
  depguard:
    rules:
      main:
        files:
          - $all
          - "!$test"
        allow:
          - $gostd
          - github.com/google # all google packages
      test:
        files:
          - "$test"
        allow:
          - $gostd
          - github.com/stretchr

Please refer to for more info: https://github.com/OpenPeeDeeP/depguard#example-configs

@black-06
Copy link
Contributor

black-06 commented Jun 6, 2023

The document needs to be updated.
It shows that the default rule is none

@ldez
Copy link
Member

ldez commented Jun 6, 2023

I already created a PR for that #3879.
We are currently migrating our documentation build system #3884.

dkoshkin added a commit to mesosphere/konvoy-image-builder that referenced this issue Jun 6, 2023
New version of golangci-lint pulled in a new version of depguard that changed the API, see golangci/golangci-lint#3877
dkoshkin added a commit to mesosphere/konvoy-image-builder that referenced this issue Jun 6, 2023
New version of golangci-lint pulled in a new version of depguard that changed the API, see golangci/golangci-lint#3877
dkoshkin added a commit to mesosphere/konvoy-image-builder that referenced this issue Jun 6, 2023
New version of golangci-lint pulled in a new version of depguard that changed the API, see golangci/golangci-lint#3877
ldemailly added a commit to fortio/fortio that referenced this issue Jun 8, 2023
ldemailly added a commit to fortio/fortio that referenced this issue Jun 12, 2023
* go1.20.5 build image

* give up on depguard. golangci/golangci-lint#3877

* make linters happy
dkoshkin added a commit to mesosphere/konvoy-image-builder that referenced this issue Jun 30, 2023
New version of golangci-lint pulled in a new version of depguard that changed the API, see golangci/golangci-lint#3877
dkoshkin added a commit to mesosphere/konvoy-image-builder that referenced this issue Jun 30, 2023
New version of golangci-lint pulled in a new version of depguard that changed the API, see golangci/golangci-lint#3877
anoopcs9 added a commit to anoopcs9/samba-operator that referenced this issue Jul 31, 2023
* Removes already deprecated[1] linter varcheck
* Depguard now expects a list of allow/deny list and default rule is to
  allow only std lib in all files[2]. Therefore disable the linter.

[1] https://golangci-lint.run/product/roadmap/#v1490
[2] golangci/golangci-lint#3877 (comment)

Signed-off-by: Anoop C S <anoopcs@samba.org>
anoopcs9 added a commit to anoopcs9/samba-operator that referenced this issue Aug 16, 2023
* Removes already deprecated[1] linter varcheck
* Depguard now expects a list of allow/deny list and default rule is to
  allow only std lib in all files[2]. Therefore disable the linter.

[1] https://golangci-lint.run/product/roadmap/#v1490
[2] golangci/golangci-lint#3877 (comment)

Signed-off-by: Anoop C S <anoopcs@samba.org>
obnoxxx pushed a commit to anoopcs9/samba-operator that referenced this issue Aug 21, 2023
* Removes already deprecated[1] linter varcheck
* Depguard now expects a list of allow/deny list and default rule is to
  allow only std lib in all files[2]. Therefore disable the linter.

[1] https://golangci-lint.run/product/roadmap/#v1490
[2] golangci/golangci-lint#3877 (comment)

Signed-off-by: Anoop C S <anoopcs@samba.org>
mergify bot pushed a commit to samba-in-kubernetes/samba-operator that referenced this issue Aug 23, 2023
* Removes already deprecated[1] linter varcheck
* Depguard now expects a list of allow/deny list and default rule is to
  allow only std lib in all files[2]. Therefore disable the linter.

[1] https://golangci-lint.run/product/roadmap/#v1490
[2] golangci/golangci-lint#3877 (comment)

Signed-off-by: Anoop C S <anoopcs@samba.org>
cfergeau added a commit to cfergeau/quill that referenced this issue Apr 18, 2024
This requires additional configuration golangci/golangci-lint#3877 (comment)
With the default config, a lot of errors are reported.
cfergeau added a commit to cfergeau/quill that referenced this issue Apr 18, 2024
This requires additional configuration golangci/golangci-lint#3877 (comment)
With the default config, a lot of errors are reported.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
cfergeau added a commit to cfergeau/quill that referenced this issue Apr 19, 2024
This requires additional configuration golangci/golangci-lint#3877 (comment)
With the default config, a lot of errors are reported.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants