Closed
Description
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'm using the latest built binary in WSL2. I noticed that the GOPATH
is not set correctly.
$ GL_DEBUG=loader,env golangci-lint run
DEBU [env] Read go env for 19.281731ms: map[string]string{"GOCACHE":"/home/mike/.cache/go-build", "GOROOT":"/home/mike/go"}
DEBU [loader] Built loader args are [./...]
DEBU [loader] 17.005851ms for GOROOT=/home/mike/go GOPATH= GO111MODULE=off GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -e -f {{context.ReleaseTags}} -- unsafe
DEBU [loader] 17.596434ms for GOROOT=/home/mike/go GOPATH= GO111MODULE= GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe
DEBU [loader] 34.693906ms for GOROOT=/home/mike/go GOPATH= GO111MODULE= GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -e -json -compiled=true -test=true -export=true -deps=true -find=false -- ./...
DEBU [loader] loaded 0 pkgs
DEBU [loader] package with tests: map[string]bool{}
ERRO Running error: context loading failed: no go files to analyze
So if I attach the GOPATH
env explicitly, it works very well:
$ GOPATH=/home/mike/go GL_DEBUG=loader,env golangci-lint run
DEBU [env] Read go env for 22.351153ms: map[string]string{"GOCACHE":"/home/mike/.cache/go-build", "GOROOT":"/home/mike/go"}
DEBU [loader] Built loader args are [./...]
DEBU [loader] 16.319336ms for GOROOT=/home/mike/go GOPATH=/home/mike/go GO111MODULE=off GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -e -f {{context.ReleaseTags}} -- unsafe
DEBU [loader] 16.946997ms for GOROOT=/home/mike/go GOPATH=/home/mike/go GO111MODULE= GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -f "{{context.GOARCH}} {{context.Compiler}}" -- unsafe
DEBU [loader] 464.214025ms for GOROOT=/home/mike/go GOPATH=/home/mike/go GO111MODULE= GOPROXY= PWD=/home/mike/work/risingwave-cloud/mgmt go list -e -json -compiled=true -test=true -export=true -deps=true -find=false -- ./...
DEBU [loader] loaded 54 pkgs
......
The GOPATH is shown in the debug log and the loader loads 54 pkgs successfully.
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.50.1 built from (unknown, mod sum: "h1:C829clMcZXEORakZlwpk7M4iDw2XiwxxKaG504SZ9zY=") on (unknown)
Configuration file
# This file contains all available configuration options
# with their default values (in comments).
# Options for analysis running.
run:
# concurrency: 4
# Timeout for analysis, e.g. 30s, 5m.
timeout: 5m
# Which dirs to skip: issues from them won't be reported.
# skip-dirs:
# - src/external_libs
# - autogenerated_by_my_lib
# Enables skipping of directories:
# - vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true
# Which files to skip: they will be analyzed, but issues from them won't be reported.
# skip-files:
# - ".*\\.my\\.go$"
# - lib/bad.go
# Allow multiple parallel golangci-lint instances running.
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false
# output configuration options
output:
# Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
format: colored-line-number
# Print lines of code with issue.
print-issued-lines: true
# Print linter name in the end of issue text.
print-linter-name: true
# Make issues output unique by line.
uniq-by-line: true
# All available settings of specific linters.
linters-settings:
gofmt:
simplify: false
goimports:
# Put imports beginning with prefix after 3rd-party packages.
# It's a comma-separated list of prefixes.
local-prefixes: github.com/risingwavelabs/risingwave-cloud
govet:
# Settings per analyzer.
settings:
# Analyzer name, run `go tool vet help` to see all analyzers.
printf:
# Run `go tool vet help printf` to see available settings for `printf` analyzer.
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
# Enable analyzers by name.
# Run `go tool vet help` to see all analyzers.
enable:
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- errorsas
# - fieldalignment
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- nonamedreturns
- printf
- reflectvaluecompare
# - shadow
- shift
- sigchanyzer
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
staticcheck:
go: "1.18"
# https://staticcheck.io/docs/options#checks
checks: [ "all" ]
stylecheck:
go: "1.18"
# https://staticcheck.io/docs/options#checks
checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ]
# https://staticcheck.io/docs/options#dot_import_whitelist
dot-import-whitelist:
- fmt
# https://staticcheck.io/docs/options#initialisms
initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ]
# https://staticcheck.io/docs/options#http_status_code_whitelist
http-status-code-whitelist: [ "200", "400", "404", "500" ]
linters:
disable-all: false
enable:
- godot
- gofmt
- goimports
- govet
- staticcheck
- stylecheck
- errcheck
- unused
- gosimple
issues:
# exclude:
# - abcdef
# Fix found issues (if it's supported by the linter).
fix: false
Go environment
$ go version && go env
go version go1.18.2 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mike/.cache/go-build"
GOENV="/home/mike/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mike/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mike/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/mike/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/mike/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/mike/work/risingwave-cloud/mgmt/go.mod"
GOWORK=""
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-build1160342141=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/mike/work/risingwave-cloud/mgmt /home/mike/work/risingwave-cloud /home/mike/work /home/mike /home /]
INFO [config_reader] Used config file .golangci.yaml
INFO [lintersdb] Active 11 linters: [errcheck godot gofmt goimports gosimple govet ineffassign staticcheck stylecheck typecheck unused]
INFO [loader] Go packages loading at mode 575 (compiled_files|exports_file|files|types_sizes|deps|imports|name) took 69.690581ms
ERRO Running error: context loading failed: no go files to analyze
INFO Memory: 2 samples, avg is 24.3MB, max is 24.3MB
INFO Execution took 91.622774ms
Code example or link to a public repository
It's a private repo. But I'm using go 1.18 with go.mod
and go.sum
in the root directory.