Hi,
When I go get github.com/golangci/golangci-lint/cmd/golangci-lint command I get errors similar to the one below and the progress really really slow (more than 10 minutes).
Any solution to it?
Thanks
...
...
go: finding github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516
go: github.com/go-xorm/[email protected]: parsing go.mod: unexpected module path "xorm.io/core"
go: finding golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01
go: github.com/Unknwon/[email protected]: parsing go.mod: unexpected module path "github.com/unknwon/i18n"
go: finding github.com/siddontang/ledisdb v0.0.0-20190202134119-8ceb77e66a92
go: finding cloud.google.com/go v0.33.1
go: finding github.com/mattn/go-oci8 v0.0.0-20181115070430-6eefff3c767c
go: finding github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2
go: gopkg.in/stretchr/[email protected]: go.mod has non-....v1 module path "github.com/stretchr/testify" at revision v1.4.0
go: github.com/Unknwon/[email protected]: parsing go.mod: unexpected module path "github.com/unknwon/com"
go: finding github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
go: finding github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76
go: finding github.com/Azure/azure-sdk-for-go v33.4.0+incompatible
go get: error loading module requirements
make[1]: *** [lint] Error 1
make: *** [style] Error 2
...
...
go: finding github.com/gorilla/sessions v1.1.1
go: gopkg.in/src-d/[email protected]: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /Users/BentCoder/Server/Go/pkg/mod/cache/vcs/67698a57fcf1e2e2f3930542ab0263846a1ad71c488399c086e4929ccb6a539b: exit status 128:
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
go: finding golang.org/x/tools v0.0.0-20190620154339-431033348dd0
go: finding github.com/shurcooL/sanitized_anchor_name v0.0.0-20160918041101-1dba4b3954bc
go: finding github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9
go: error loading module requirements
$ cat ~/.bash_profile
export GOPATH="$HOME/Server/Go"
export GO111MODULE="on"
export PATH=$PATH:$GOPATH/bin
$ golangci-lint --version
golangci-lint has version v1.18.0 built from (unknown, mod sum: "h1:XmQgfcLofSG/6AsQuQqmLizB+3GggD+o6ObBG9L+VMM=") on (unknown)
# .golangci.yml
# Options for analysis running.
run:
# Default concurrency is a available CPU number.
concurrency: 4
# Timeout for analysis. e.g. 30s, default is 1m.
deadline: 2m
# Exit code when at least one issue was found, default is 1.
issues-exit-code: 10
# Include test files, default is true.
tests: true
# Output configuration options.
output:
# Output styling.
# e.g. colored-line-number, line-number, json, tab, checkstyle, code-climate.
# Default is colored-line-number.
format: colored-line-number
# Print lines of code with issue, default is true.
print-issued-lines: true
# Print linter name in the end of issue text, default is true.
print-linter-name: true
# All available settings of specific linters.
linters-settings:
# Checks whether code was formatted.
gofmt:
# Simplify code: gofmt with `-s` option, true by default.
simplify: true
# Computes and checks the cyclomatic complexity of functions.
gocyclo:
# Minimal code complexity to report, 30 by default but recommend 10-20.
min-complexity: 10
# Detects Go structs that would take less memory if their fields were sorted.
maligned:
# Print struct with more effective memory layout, false by default.
suggest-new: true
# Detects code cloning.
dupl:
# Tokens count to trigger issue, 150 by default.
threshold: 100
# Checks if package imports are in a list of acceptable packages.
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/davecgh/go-spew/spew
# Finds commonly misspelled English words in comments.
misspell:
# Correct spellings using locale preferences for UK.
locale: UK
# Reports long lines.
lll:
# Max line length, lines longer will be reported, 120 by default.
line-length: 120
# Tab width in spaces, 1 by default.
tab-width: 1
# List of enabled linters.
linters:
enable:
- bodyclose
- deadcode
- dupl
- errcheck
- goconst
- gocritic
- gocyclo
- goimports
- gosimple
- gosec
- govet
- ineffassign
- interfacer
- lll
- maligned
- misspell
- nakedret
- staticcheck
- structcheck
- stylecheck
- unconvert
- unparam
- unused
- varcheck
enable-all: false
fast: false
# Linter exception and limit rules.
issues:
# Excluding configuration per-path, per-linter, per-text and per-source.
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- lll
# Independently from option "exclude" option (if set), let default exclude patterns be used.
# Default is true.
exclude-use-default: true
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0
$ go version && go env
go version go1.12.7 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/BentCoder/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/BentCoder/Server/Go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/BentCoder/Server/Go/src/github.com/BentCoder/auth/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pr/g7230wl10mnf0fnqd6cc1_f80000gn/T/go-build586231787=/tmp/go-build -gno-record-gcc-switches -fno-common"
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/BentCoder/Server/Go/src/github.com/BentCoder/auth /Users/BentCoder/Server/Go/src/github.com/BentCoder /Users/BentCoder/Server/Go/src/github.com /Users/BentCoder/Server/Go/src /Users/BentCoder/Server/Go /Users/BentCoder/Server /Users/BentCoder /Users /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [lintersdb] Optimized sublinters [staticcheck gosimple unused] into metalinter megacheck
INFO [loader] Go packages loading at mode 991 (deps|imports|syntax|types_info|types_sizes|compiled_files|files|name|types) took 2.013361384s
INFO [loader] SSA repr building timing: packages building 16.808233ms, total 180.000051ms
INFO [runner] worker.4 took 2.928265ms with stages: errcheck: 1.425967ms, varcheck: 704.442碌s, deadcode: 525.936碌s, structcheck: 229.532碌s, typecheck: 18.807碌s
INFO [runner] worker.3 took 293.267578ms with stages: ineffassign: 293.258953ms
INFO [runner] worker.2 took 456.87316ms with stages: govet: 456.863795ms
INFO [runner] worker.1 took 1.585134045s with stages: megacheck: 1.585127269s
INFO [runner] Workers idle times: #2: 1.112442363s, #3: 1.274617771s, #4: 1.565005653s
INFO [runner] processing took 6.741碌s with stages: nolint: 2.941碌s, max_same_issues: 880ns, skip_dirs: 546ns, max_from_linter: 467ns, cgo: 438ns, filename_unadjuster: 215ns, diff: 166ns, path_prettifier: 160ns, identifier_marker: 159ns, exclude: 108ns, source_code: 103ns, skip_files: 100ns, uniq_by_line: 98ns, max_per_file_from_linter: 92ns, autogenerated_exclude: 91ns, exclude-rules: 90ns, path_shortener: 87ns
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 34 samples, avg is 309.6MB, max is 741.3MB
INFO Execution took 3.93779593s
@BentCoder It looks like you are using Go 1.12.x which doesn't use the module proxy by default. Try enabling the proxy by setting the GOPROXY=proxy.golang.org envvar or upgrading to Go 1.13 which does this by default to see if it speeds things up.
Thanks @tpounds Upgrading was the solution.
Most helpful comment
@BentCoder It looks like you are using Go 1.12.x which doesn't use the module proxy by default. Try enabling the proxy by setting the
GOPROXY=proxy.golang.orgenvvar or upgrading to Go 1.13 which does this by default to see if it speeds things up.