Skip to content

Required access since v1.44.0 ist undocumented #2523

Closed
@bosix

Description

@bosix

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

I've updated golangci-lint from v1.43.0 to v1.44.0. Since then I get an error when running the tool inside an environment which does not have full access to all 3rd party libraries from go.mod. This can happen when private libraries are used inside the go project.

The error disappears when I completely setup the environment including a setup of GOPRIVATE and proper access to the secured libraries (I use git for this purpose) but I think it should be mentioned anywhere in the docs that since v1.44.0 golangci-lint needs access to all libraries from go.mod.

Version of golangci-lint

Used docker image: golangci/golangci-lint:v1.44.0-alpine@sha256:8ac9a08a9e2f627cdc2dcae7255308ca63aa56f3015bb9d3d650692b1c52c768

Configuration file

$ cat .golangci.yml
output:
    sort-results: true

linters:
    disable-all: true
    #    https://golangci-lint.run/usage/linters/
    enable:
        - asciicheck    # check for non-ascii chars in identifiers (vars, functions, types, ...)
        - bodyclose # check for unclosed bodies of http requests (does not work in very complex scenarios)
        - deadcode  # check unused code
        - dupl  # check for duplicates with at least 100 chars (can be changed via config)
        - durationcheck # check for 2 durations which are multiplied by accident
        - errcheck  # check that all errors are handled
        - exportloopref # check for exported pointers on loop variables
        - funlen #check for too long functions (default: 60 lines or 40 statements)
        - gocognit  # check for functions with too high cognitive complexity
        - goconst   # check for multiple used strings with could be replaced by a const
        - godox # check for todos and fixmes
        - gofumpt   # check against the coding standard rules of https://github.com/mvdan/gofumpt (an extension of gofmt)
        - gomnd # check magic numbers
        - gosimple  # check if code can be simplified e.g. !condition instead of condition == false
        - govet     # check incorrect printf format-argument calls
        - ifshort   # check for if-statements which can be replaced by short version
        - ineffassign   # check unused assignments to existing vars
        - lll   # check max line length
        - nilerr    # check if function returns nil although a checked error is not nil
        - paralleltest # check if t.Parallel() is used in all tests
        - predeclared # check that definitions (vars, functions, ...) do not use predeclared names like int, string, copy, print, ...
        - revive    # linter (replaces golint)
        - unconvert # check unnecessary type conversions
        - unparam   # check (well... it tries) to find unused func params or returns
        - unused    # check unused constants, functions, types, vars and struct fields

linters-settings:
    gocognit:
        min-complexity: 15

issues:
    exclude-rules:
        -   path: _test\.go
            linters:
                - funlen
                - errcheck
                - dupl
                - goconst
                - bodyclose
                - lll
    fix: true

Go environment

(this is the working environment)

$ go version && go env
go version go1.17.6 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/bosi/.cache/go-build"
GOENV="/home/bosi/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/bosi/go/pkg/mod"
GONOPROXY="gitlab.com/softwarepinguin/*"
GONOSUMDB="gitlab.com/softwarepinguin/*"
GOOS="linux"
GOPATH="/home/bosi/go"
GOPRIVATE="gitlab.com/softwarepinguin/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build518308105=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint run ./...
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"gitlab.com/softwarepinguin/rapi\""
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"gitlab.com/softwarepinguin/rapi\"\n\n"

Code example or link to a public repository

You just need a go project which uses a private library. I can reproduce the issue easily inside a ci/cd pipeline where the complete environment is empty.
cd pipeline

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