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

Updating go version fails to run via pre-commit #3966

Closed
5 tasks done
stdedos opened this issue Jul 21, 2023 · 1 comment
Closed
5 tasks done

Updating go version fails to run via pre-commit #3966

stdedos opened this issue Jul 21, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@stdedos
Copy link

stdedos commented Jul 21, 2023

Welcome

Description of the problem

Replicate with:

  1. In a pre-commit-enabled repository, run pre-commit run --all with one go version (e.g., 1.19)
  2. Update your PATH to use a different go version (e.g. 1.20)
  3. Run pre-commit run --all again

Expected:

Receiving the same output (hopefully clean)

Actual:

golangci-lint...................................................................................Failed
- hook id: golangci-lint
- exit code: 3

ERRO [linters_context] gocritic: load embedded ruleguard rules: rules/rules.go:13: can't load fmt: setting an explicit GOROOT can fix this problem.

Setting an explicit GOROOT can mitigate the problem, but not always.

Reminds of this issue #3107, but (a) setting language_version (esp. with minor accurancy) is an exercise in futility (go.mod already has the language version), and (b) changing the entry is also not ideal.

I'd be nice if golangci-lint would purge whatever is necessary to work again.

Version of golangci-lint

    rev: v1.53.2

Configuration

run:
  timeout: 10m
  build-tags:
    - heavy
    - heavy_idp
    - heavy_ltp

linters:
  fast: false
  enable:
    - revive
    - unparam
    - wastedassign
    - exhaustive
    - gomnd
    - gofumpt
    - stylecheck
    - prealloc
    - gocritic
    - importas

linters-settings:
  govet:
    check-shadowing: true
  gocritic:
    enabled-checks:
      # first default checks
      - appendAssign
      - argOrder
      - assignOp
      - badCall
      - badCond
      - captLocal
      - caseOrder
      - codegenComment
      # - commentFormatting # conflict with gofumpt and --fix
      - defaultCaseOrder
      - deprecatedComment
      - dupArg
      - dupBranchBody
      - dupCase
      - dupSubExpr
      - elseif
      - exitAfterDefer
      - flagDeref
      - flagName
      - ifElseChain
      - mapKey
      - newDeref
      - offBy1
      - regexpMust
      - singleCaseSwitch
      - sloppyLen
      - sloppyTypeAssert
      - switchTrue
      - typeSwitchVar
      - underef
      - unlambda
      - unslice
      - valSwap
      - wrapperFunc
      # non-defaults
      # perf
      - appendCombine
      - equalFold
      - indexAlloc
      - preferDecodeRune
      - preferFprint
      - preferStringWriter
      - preferWriteByte
      - rangeExprCopy
      - sliceClear
      - stringXbytes
      # style
      - boolExprSimplify
      - commentedOutImport
      - deferUnlambda
      - emptyStringTest
      - hexLiteral
      - httpNoBody
      - importShadow
      - initClause
      - methodExprCall
      - preferFilepathJoin
      - ptrToRefParam
      - redundantSprint
      - regexpSimplify
      - stringConcatSimplify
      - timeExprSimplify
      - typeDefFirst
      - typeUnparen
      - unlabelStmt
      - unnecessaryBlock
      - yodaStyleExpr
      # diagnostics
      - badLock
      - badRegexp
      - builtinShadowDecl
      - emptyDecl
      - evalOrder
      - externalErrorReassign
      - filepathJoin
      - nilValReturn
      - regexpPattern
      - returnAfterHttpError
      - sloppyReassign
      - sortSlice
      - sprintfQuotedString
      - sqlQuery
      - syncMapLoadAndDelete
      - truncateCmp
      - unnecessaryDefer
      - weakCond

issues:
  exclude-rules:
    - linters:
        - revive
      text: "var-naming: don't use leading k in Go names"
    - linters:
        - revive
      text: "package-comments: should have a package comment"
    - linters:
      - unparam
      text: "always receives"
  include:
    - EXC0012
    - EXC0013
    - EXC0014

severity:
  default-severity: Major

output:
  uniq-by-line: false

Go environment

$ go version && go env
go version go1.20.6 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="~/.cache/go-build"
GOENV="~/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="~/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="~/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.20"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.20/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="~/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-build1365341874=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

Does not apply

$ golangci-lint cache clean
$ golangci-lint run -v
# paste output here

Code example or link to a public repository

Proprietary

Validation

  • Yes, I've included all information above (version, config, etc.).
@stdedos stdedos added the bug Something isn't working label Jul 21, 2023
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels Jul 21, 2023
@ldez
Copy link
Member

ldez commented Jul 21, 2023

Duplicate of #3107

Take a look to #3107 (comment)

@ldez ldez closed this as completed Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants